๐ What Is accent-color?
The accent-color property allows you to easily customize the color of form controls such as:
- โ Checkboxes
- โ Radio buttons
- โ Range sliders
- โ Progress bars
- โ Meter elements
Before accent-color, customizing these UI elements required complex techniques. Now, one line of CSS updates all the browser-defined accent UI parts.
Note
โ Enhances UI consistency
โ Works with both light and dark modes
๐ฆ Syntax
Basic syntax
accent-color: auto | <color>;| Value | Description |
|---|---|
| auto | Browser decides the accent color (default). |
| <color> | Any valid CSS color (hex, rgb, hsl, color(), etc.). |
๐ 1. Apply Accent Color to Form Inputs
Simple accent color
input[type="checkbox"],
input[type="radio"] {
accent-color: #ff5722; /* Orange */
}All checkboxes and radio buttons adopt the orange accent.
๐ 2. Use Accent Color on Range Sliders
Range slider
input[type="range"] {
accent-color: #4caf50; /* Green */
}The slider thumb and filled track portion use the custom accent color.
๐ 3. Accent Color for Progress & Meter Elements
Progress styling
progress, meter {
accent-color: hsl(220, 80%, 60%);
}Applies theme colors to progress bars and meter indicators.
๐ 4. Dark Mode Friendly Accent Colors
Dark mode UI
:root {
accent-color: #00bcd4;
}
@media (prefers-color-scheme: dark) {
:root {
accent-color: #80deea;
}
}Automatically adjusts accent color for dark mode.
๐ 5. Using CSS Variables With Accent Color
CSS variable
:root {
--brand-color: #9c27b0;
}
input[type="checkbox"] {
accent-color: var(--brand-color);
}Great for applying theme systems across applications.
๐ 6. Accent Color for Theming UI Components
Themed form
.theme-red input[type="checkbox"] {
accent-color: crimson;
}
.theme-blue input[type="checkbox"] {
accent-color: royalblue;
}Useful in dashboards, settings screens, and user-customizable UIs.
๐งช Real-World Examples
1๏ธโฃ Settings Page UI
Settings panel
.settings input[type="checkbox"] {
accent-color: #03a9f4;
}2๏ธโฃ Todo List App
Todo app
.todo-item input[type="checkbox"] {
accent-color: #ff9800;
}3๏ธโฃ Survey Form Radio Buttons
Survey form
input[type="radio"] {
accent-color: #4caf50;
}โ ๏ธ Common Mistakes
- โ Expecting accent-color to style borders or backgrounds of inputs
- โ Using accent-color on unsupported elements (like text inputs)
- โ Applying accent-color but forgetting browser fallback styles
Note
๐ฅ Summary
The accent-color property is a powerful and simple way to theme built-in form controls to match your application's brand style. It improves UI consistency, accessibility, and aesthetics with minimal code.
Learn more โMDN Docs ๐