CSS Reference ยท Colors and Backgrounds
The accent-color property
Reference for the CSS accent-color property: recolor checkboxes, radio buttons, range sliders and progress bars without rebuilding them, with examples.
The accent-color property sets the highlight color of built-in form controls: the checked state of checkboxes and radio buttons, the filled part of a range slider, and the bar of a <progress> element. The control keeps its native look, behavior and accessibility; only the main color changes.
The browser chooses a readable color for anything drawn on top of your accent, such as the check mark, so you do not have to worry about contrast for that part.
input[type="checkbox"] { accent-color: #7c3aed; }
Try it
Because accent-color inherits, setting it on a wrapper (here, each row) colors every supported control inside.
Syntax
accent-color: auto | <color>
- Initial value:
auto - Applies to: all elements (it has an effect on checkboxes, radio buttons, range inputs and
<progress>) - Inherited: yes
- Animatable: yes, as a color
- Computed value:
auto, or the computed color
Values
| Value | Description |
|---|---|
auto |
Uses the browser or operating system default accent color. |
<color> |
Any CSS color: a keyword, hex value, rgb(), oklch() and so on. See color values. |
Usage notes
- The cheapest way to brand a form. One declaration on
:rootorbodyrecolors every checkbox, radio, range and progress bar, with no custom markup and no loss of keyboard or screen reader support. - Which controls are affected can differ slightly between browsers. Text fields, selects and buttons are not recolored by this property. Use
appearanceand your own styles when you need full control. - Keep contrast in mind. The accent is drawn against the page background and the unchecked track. A very pale accent on a white page can make the checked state hard to see.
- It follows the color scheme. In a dark scheme (see
color-scheme) the browser adapts the surrounding parts of the control to the accent. - Pairs well with
caret-color. Setting both gives text inputs and toggles one consistent highlight. - It does not change focus rings. Use
outlinefor those.
Browser support
Supported in current versions of all major browsers and part of Baseline; check a compatibility table for older releases.
Related
color-schemeโ light and dark control renderingappearanceโ removes native styling entirelycaret-colorโ color of the text caret- Lessons: Forms, User Interface