Theming
ARC UI's colors come from CSS custom properties. One attribute switches the mode, and overriding tokens gives you a theme of your own.
How themes work
The data-theme attribute on <html> sets the mode. There are three:
data-theme="dark"The default. Near-black surfaces with blue and violet accents.data-theme="light"Light backgrounds, with darker accents for contrast.data-theme="auto"Follows the OS setting through prefers-color-scheme.Components restyle as soon as the attribute changes. On this site, the toggle in the top bar changes it.
Dark mode
Dark is the default, so the attribute is optional.
<!-- Dark mode is the default — no attribute needed -->
<html>
<!-- or explicitly: -->
<html data-theme="dark">
The background tokens, rendered on this page:
--bg-deep--bg-surface--bg-card--bg-elevatedLight mode
In light mode, shadows are tinted with the accent colors instead of black.
<html data-theme="light">
Auto mode
Auto follows the OS setting through prefers-color-scheme. To keep a visitor's own choice across visits, store it and restore it on load:
// Set theme and persist
function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('arc-theme', theme);
}
// Restore on page load
const saved = localStorage.getItem('arc-theme') || 'auto';
document.documentElement.setAttribute('data-theme', saved);
arc-theme-toggle does this for you. It stores the choice in localStorage under arc-theme.Fixed regions
.theme-fixed-dark and .theme-fixed-light keep a subtree in one scheme whatever the page theme is, for regions like a nav, a footer or a command bar. The class applies the same scheme the library generates for :root, so a pinned region has the contrast that scheme was tuned for.
<div class="theme-fixed-dark">
<arc-top-bar fixed>
<!-- Dark tokens, whatever the page is doing -->
</arc-top-bar>
</div>
<aside class="theme-fixed-light">
<!-- and the reverse, for a light panel on a dark page -->
</aside>
On a page in the same scheme, a pinned region matches the page: a dark nav on a dark page is near-black. On a page in the other scheme it stops short, because near-black against near-white would be the hardest edge on the page. It uses a deep color derived from your accent instead. This site's top bar and footer work this way, and in light mode they're deep blue.
--accent-primary and its lightness from the
scheme, so overriding your accent recolors pinned regions too. A teal accent gives a
deep teal nav, and a gray one stays gray. A browser without relative color syntax
keeps the default blue in pinned regions.
Custom themes
Gradients, glows and focus rings read the accent tokens through var(). Override the two accents and their -rgb triplets (used for transparency) and those follow:
:root {
--accent-primary: rgb(0, 150, 136);
--accent-primary-rgb: 0, 150, 136;
--accent-secondary: rgb(233, 30, 99);
--accent-secondary-rgb: 233, 30, 99;
/* That's it. Glows, gradients, and focus rings recompose from these. */
}
The button below applies those four lines to this page:
Theme Synthesizer
The Theme Synthesizer edits colors, fonts, type sizes, spacing, radii, layout sizes and durations with a live preview. It exportsarc-theme.css with only the tokens you changed, to load afterbase.css.
See also
- Design tokens: every token group, with values
- Theme Synthesizer: build a theme with a live preview
- Theme toggle: a button that cycles through the three modes