Browser-Generated UI Theming: color-scheme, accent-color, Scrollbars, and Form Controls
How to theme native scrollbars, form controls, and light/dark UI with color-scheme, accent-color, light-dark(), and related CSS without rebuilding components.
This page summarizes Chrome Modern Web Guidance on customizing browser-generated UI—scrollbars, checkboxes, sliders, <select> pickers, text selection, and canvas chrome—with CSS before replacing native controls. The pattern is progressive enhancement: modern properties apply where supported; older browsers keep familiar platform UI.
color-scheme and light-dark(): how native UI follows light and dark mode
Section titled “color-scheme and light-dark(): how native UI follows light and dark mode”The color-scheme property tells the browser which schemes your page supports so it can theme native surfaces (scrollbars, form controls, default canvas) and reduce flashes of the wrong theme on load.
The color-scheme property indicates which color schemes (such as light or dark) your page supports. This informs the browser that it can automatically theme native UI elements—like scrollbars, form controls, and the default canvas background—to match your site’s design and help minimize white flashes during initial loading.
— Chrome, Dark mode
Declare support early in HTML and mirror it in CSS on :root or html, not only on body, because the root element drives viewport scrollbars and the initial canvas:
<meta name="color-scheme" content="light dark">:root { color-scheme: light dark;}Pair scheme support with tokens via light-dark() so author colors and built-in UI stay aligned; keep separate light/dark raw values for fallbacks where light-dark() is missing (see Component-specific light/dark themes). For components that must always render as dark or light (code blocks, embeds), set color-scheme on that subtree—and re-apply inherited color properties such as color and accent-color, because light-dark() resolves at computed-value time and descendants may otherwise get a frozen light or dark color.
accent-color: brand color on checkboxes, radios, range, and progress
Section titled “accent-color: brand color on checkboxes, radios, range, and progress”accent-color tints several native controls in one declaration without sacrificing semantics or keyboard behavior:
The CSS property accent-color provides a simple way to bring your brand color to built-in HTML form inputs with a single line of CSS, without sacrificing accessibility or built-in browser features.
— Chrome, Brand-Consistent Forms
Apply it on a container or html:
html { accent-color: light-dark(var(--color-accent-light), var(--color-accent-dark));}It currently affects checkbox, radio, input[type="range"], and <progress>—not every control. For a quick win on sliders, see Brand-Consistent Range Slider; for switches, use <input type="checkbox" switch> with the same property (Build Accessible Switch Controls).
accent-color limits and contrast bugs
Section titled “accent-color limits and contrast bugs”Do not assume the browser always picks a visible checkmark or thumb indicator:
DO NOT blindly trust the browser to handle contrast. While browsers are supposed to automatically determine an eligible contrast color, known bugs in implementations like Safari (WebKit bug 244233) and Android Chrome (Chromium bug 343503163) can fail to invert checkmark colors, leading to invisible or hard-to-see controls when using colors that lack sufficient contrast against the background.
— Chrome, Brand-Consistent Forms
Safari may keep a white or black indicator while changing only the fill behind it (Dark mode, Styling Checkboxes). Test brand colors in light and dark schemes. When accent-color is not enough, use appearance: none and pseudo-elements (Styling Checkboxes) or gate custom fallbacks with @supports not (accent-color: …) (Brand-Consistent Forms).
scrollbar-color and scrollbar-width: thumb, track, and macOS overlay behavior
Section titled “scrollbar-color and scrollbar-width: thumb, track, and macOS overlay behavior”Standard properties scrollbar-color (thumb, then track) and scrollbar-width (auto, thin, none) style scrollbars on the scrollable element (Customize the color or thickness of a scrollbar, Scrollbar styling):
.scroller { --scrollbar-thumb: light-dark(#999, #666); --scrollbar-track: light-dark(#eee, #222); scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); scrollbar-width: thin;}scrollbar-width: none hides the bar but leaves scrolling; avoid that unless another affordance replaces scrolling (Theming browser-generated UI).
High contrast and macOS gotchas
Section titled “High contrast and macOS gotchas”Under @media (prefers-contrast: more), override thumb and track with stark colors if your theme uses low-contrast scrollbars (Adapt scrollbar to high-contrast preferences).
On macOS, overlay scrollbars ignore custom colors unless you also set scrollbar-width (e.g. thin). Tracks may stay transparent even with scrollbar-gutter: stable; the thumb must remain visible without relying on the track (Dark mode, Adapt scrollbar to high-contrast preferences).
Do not animate or transition scrollbar-color—WebKit can flicker on each change. For Baseline-widely-available targets, wrap ::-webkit-scrollbar fallbacks in @supports not (scrollbar-color: auto) so they do not fight standard properties (Customize the color or thickness of a scrollbar).
appearance base-select: branded and rich <select> without losing the native control
Section titled “appearance base-select: branded and rich <select> without losing the native control”For dropdowns that need custom layout, icons, or animation, opt in with appearance: base-select on both the <select> and ::picker(select):
By opting into appearance: base-select, you gain access to the internal shadow DOM of the select element, allowing you to style the button, the options picker list, the arrow icon, and the checkmark indicator using standard CSS properties.
— Chrome, Branded Select Styling
Use <button> with <selectedcontent> inside the select for the closed-state label; style the open list via ::picker(select) (top-layer, no z-index fights). Grid or card layouts belong on select:open::picker(select)—styling the picker without :open can leave it visible when closed (Custom Select Picker Layouts). Entry animations use @starting-style, transition-behavior: allow-discrete, and prefers-reduced-motion overrides (Animated Select Picker).
Unsupported browsers fall back to the OS dropdown; markup inside <option> may be stripped—keep option text meaningful (Rich Media Picker). Opting in replaces native mobile pickers with web-rendered menus—skip base-select when you depend on the OS wheel UI (Branded Select Styling).
Progress and range: semantic elements and when accent-color is not enough
Section titled “Progress and range: semantic elements and when accent-color is not enough”Use native <progress> for task completion (implicit progressbar role) and labeled input[type="range"] for adjustable values (Build a Styled Progress Bar, Brand-Consistent Range Slider). WHATWG expects user agents to distinguish determinate and indeterminate bars and follow platform conventions for direction and writing mode (15 Rendering — The progress element).
Limited styling: accent-color, size, and some paint effects. Properties like border-radius or background on <progress> can silently disable default styling—then use appearance: none and separate ::-webkit-progress-value / ::-moz-progress-bar rules, never combined in one selector (Build a Styled Progress Bar). For full track/thumb control on range inputs, reset with appearance: none and style WebKit and Mozilla pseudo-elements in separate blocks (Brand-Consistent Range Slider).
Contrast, forced colors, and dynamic text on colored backgrounds
Section titled “Contrast, forced colors, and dynamic text on colored backgrounds”Baseline targets: about 4.5:1 for normal text and 3:1 for large text and non-text UI boundaries (Color). In Forced Colors Mode, backgrounds, shadows, and many images are overridden—use system color keywords and @media (forced-colors: active) rather than forced-color-adjust: none except where color is essential (Color).
For badges or buttons with variable backgrounds, contrast-color() picks foreground black or white against a given background (Ensure text readability with dynamic background colors).
Validity styling: prefer :user-valid / :user-invalid over :valid / :invalid so empty required fields are not errors on first paint; exclude range inputs when styling fields broadly (Theming browser-generated UI).
Common mistakes when theming browser-generated UI
Section titled “Common mistakes when theming browser-generated UI”| Mistake | Why it hurts | What to do instead |
|---|---|---|
| Rebuilding selects or sliders in JavaScript first | Loses native AT, IME, and form integration | Try accent-color, base-select, and pseudo-elements per Theming browser-generated UI |
color-scheme only on body |
Root scrollbars/canvas may stay light | Set on :root / html (Dark mode) |
Grouping ::-webkit-* and ::-moz-* in one rule |
Entire rule dropped in some engines | Split per engine (Build a Styled Progress Bar) |
user-select: none on content |
Breaks copy, translation, AT reading | Restrict to chrome (Theming browser-generated UI) |
| State by color alone on custom options | Fails WCAG and forced colors | Add weight, border, or checkmark (Animated Select Picker) |
When to customize native UI vs build custom components
Section titled “When to customize native UI vs build custom components”Before re-creating browser UI (form controls, scrollbars, selections, error messages, etc), first verify that: the browser UI cannot be customized enough for your needs, even with modern CSS, the desired customization is sufficiently critical to justify the tradeoffs of re-creating built-in UI — most notably losing accessible semantics, keyboard handling, IME, and AT integration that the native UI provides for free.
— Chrome, Theming browser-generated UI
Choice cards can use label:has(:checked) with non-layout-affecting emphasis (Build a Card). Optional site theme toggles are rare for general audiences; most pages should follow the system scheme (Dark mode toggles).
How to check this on your site
Section titled “How to check this on your site”-
Open the site with system light and dark preferences and confirm root scrollbars, form controls, and page background match—
color-schemeshould be on:rootper Dark mode. -
Inspect checkboxes, radios, range inputs, and
<progress>with your brandaccent-color; verify checkmarks and thumbs in Safari and Chromium using Brand-Consistent Forms and Styling Checkboxes. -
Scroll a tall region and confirm thumb versus track contrast (including
@media (prefers-contrast: more)if used) per Adapt scrollbar to high-contrast preferences. -
If you use
appearance: base-select, test keyboard open/close, form submitname/value, and fallback text-only options in an older browser (Branded Select Styling). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact passage you are asking about so it can be corrected or explained.