CSS propertyInteraction and more
accent-color
Changes the accent colour of form controls: checkboxes, radio buttons, sliders, and progress bars.
- Initial value
auto- Inherited
- Yes
- Animatable
- yes, as a colour
- Applies to
- checkboxes, radio buttons, sliders, and progress bars
- JavaScript
element.style.accentColor = "#7c3aed"
Example
#CSS
:root {
accent-color: #a78bfa;
}Example HTML
<div style="accent-color: #a78bfa; display: grid; gap: 8px;">
<label><input type="checkbox" checked> Daily reminder</label>
<label>Difficulty level <input type="range" value="40"></label>
</div>Preview
Definition and usage
#The accent-color property lets you colour native controls in one line: checked checkboxes, radio buttons, range sliders, and progress bars. You don’t need to build custom controls from scratch.
The browser itself picks the colour of the mark (for example the tick in a checkbox) so it is readable on the chosen accent.
The property is inherited, so set on :root it colours all controls in the document.
Syntax
#Syntax
accent-color: auto | <color>;Values
#Values in practice
#auto
The default browser and system colour.
.demo { accent-color: auto; }#7c3aed
Purple controls.
.demo { accent-color: #7c3aed; }#10b981
Green controls.
.demo { accent-color: #10b981; }Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- Before building your own checkbox, check whether
accent-coloris enough. Native controls are available right away. - Check the accent’s contrast against the background, especially in dark mode.
Related entries
#Practise it in lessons
#Spotted a mistake or missing an example? Write to us.