Custom Form Elements
Goal: Create custom-styled form elements with accessibility in mind.
1. Checkbox
input[type="checkbox"] {
appearance: none;
width: 18px;
height: 18px;
border: 2px solid #007bff;
border-radius: 4px;
cursor: pointer;
}
input[type="checkbox"]:checked {
background-color: #007bff;
}
2. Select
select {
appearance: none;
background: url('arrow.svg') no-repeat right 10px center;
padding-right: 30px;
border: 1px solid #ccc;
border-radius: 4px;
}
3. Range
input[type="range"] {
width: 100%;
accent-color: #007bff;
}
Tips:
- Keep
<label>for accessibility. - Use
appearance: noneto override native styling.