Accent-color - Property CSS

accent-color

Summary of characteristics of the accent-color property

Quick description
Defines the colour of active or checked items.
Status
Standard
Usable for
HTML
Predefined values
auto | currentcolor
Initial value
auto
Inherited by default
Yes.
Animation type
Computed value : during an animation, the accent-color property gradually changes from one value to another.
W3C Module
CSS Basic User Interface Module
References (W3C)
Document status: WD (Working Draft)

The syntax scheme of accent-color.

accent-color - Syntax DiagramSyntax diagram of the accent-color CSS property. See stylescss.free.fr for details. auto auto currentcolor currentcolor color-name color-name #xxxxxx #xxxxxx color coloraccent-color:;accent-color:;
Syntax scheme of the accent-color property

Legend :

Description.

The accent-color property defines the color of the selected elements. It essentially applies to the following:

  • Checkbox when checked.  
  • Radio button when selected.  
  • Left side of the input fields of range type.  
  • Left side of the progress bars.  

Values for accent-color.

  • accent-color: auto;

    The browser decides what color the selected or checked elements (form) will be. In general, the color is chosen for Maximize contrast with unselected or unchecked items.

  • accent-color: currentColor;

    Selected or checked elements of a form will be the same color as the text.

  • accent-color: #00AA00;

    A color expressed in any of the syntaxes recognized by CSS (see Colors).

  • accent-color: initial; (auto) accent-color: inherit; accent-color: revert; accent-color: revertLayer; accent-color: unset;

    Common values ​​are presented on these pages: initial, inherit, revert, revert-layer, unset.

Animation of the property accent-color.

Like all color properties, accent-color can be animated very smoothly. In our example, the colors were set with the hsl() function.

Manipulating the accent-color property with Javascript.

With Javascript, change the value of accent-color.

Here's how to change the value of accent-color with Javascript. We see that Javascript offers a syntax with the typical CSS notation, in kebab-case (a hyphen to separate words), and another syntax with the notation in camel-case (a capital letter to separate words).

Javascript
let el = document.getElementById('id'); el.style['accent-color'] = 'cyan'; // or let el = document.getElementById('id'); el.style.accentColor = 'cyan';

With Javascript, read the value of accent-color.

This code retrieves the value of the accent-color property assigned directly to the element itself via its style attribute. or the previous code, but not the value assigned via a CSS selector.

Javascript
let el = document.getElementById('id'); let value = el.style['accent-color']; // or let el = document.getElementById('id'); let value = el.style.accentColor;

With Javascript, read the calculated value of accent-color.

The calculated value is the value that results from the evaluation of the different syntaxes for expressing a color.
The color is returned as RGB(r,g,b), or RGBA(r,g,b,a) if the opacity is not total.

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('accent-color');

With JQuery, change the value of accent-color.

JQuery

$('#id').css('accent-color', 'cyan');
// or
$('#id').css('accentColor', 'cyan');

With JQuery, read the calculated value of accent-color.

JQuery
let value = $('#id').css('accent-color');

Other code examples.

More examples of Javascript and JQuery code are given on the Javascript and CSS page.

Test it yourself.

The buttons below apply the value entered to the accent-color property and then display the value for the first button as it was applied, and for the second button, the calculated value. The latter allows you to see how the value of accent-color is stored (serialized). We can see that the color is serialized in the form rgb(...) or rgba(...).

Simulator.

When manipulating the simulator, you will notice that the right part of the sliders or the right part of the scroll bars are also impacted by the value of accent-color. Indeed, when a light color is requested for the left part, the right part is forced into a color to maintain a very sharp contrast between the right and left sides.

accent-color :

Effect on radio buttons:

Effect on checkboxes:

Effect on a range input box:

Effect on a progress element: 50%

Support for the accent-color property.

The accent-color property is well supported by current browsers, as shown by the compatibility table below (except for a particularity with Safari  ).

Column 1
Support for the accent-color property.

Notes:

(1) Safari doesn't adjust the color of glyphs on form controls to maintain contrast.

1
accent-color
property
Estimated overall support.
78%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

Baidu Browser

QQ Browser

Opéra Mobile

Firefox

Chrome

Safari

Edge

Opéra

Chrome pour Androïd

Safari sur IOS

Samsung Internet

UC Browser pour Androïd

Androïd Brower

Firefox pour Androïd

KaiOS Browser

Opéra mini

accent-color: property History.

See also, on UI stylization.

The possibilities for customizing or styling the user interface (UI) are described in the CSS Basic User Interface Module specification of W3C.

Properties:

appearance
Langue française
Sets all the properties needed for an item to be displayed as a button, menu, and so on.
caret
Langue française
Sets the color and shape of the text marker.
caret-color
Langue française
Chooses the color of the text marker (flashing cursor).
caret-shape
Langue française
Sets the shape of the text cursor.
cursor
Sets the shape of the mouse cursor.
ime-mode
Langue française
Defines the accessibility of an input box.
outline
Langue française
Summary of contour characteristics.
outline-color
Langue française
Sets the color of the outline.
outline-offset
Langue française
Sets the spacing between the outline and the element.
outline-style
Langue française
Defines the type of stroke of the contours (single, double, dashed...).
outline-width
Langue française
Sets the weight of the strokes for the outline.
resize
Langue française
Allows or prevents the element from being sized. by the user.
user-select
Langue française
Defines whether the content of an element is user-selectable or not.