Themes
A theme is five colors. Switch with one attribute; everything else (outlines, shadows, ink) is shared.
Built-in themes
Click to preview. The choice is saved in localStorage.
Switching
Two independent attributes on <html>:
| Attribute | Values | Default |
|---|---|---|
data-theme | sunny, sky, mint, lilac, tangerine, or yours | sunny |
data-mode | light, dark | follows the OS |
<html lang="en" data-theme="mint" data-mode="dark">At runtime, both are saved to localStorage:
Coverup.setTheme('lilac');
Coverup.setMode('dark'); // 'light' | 'dark' | 'system'Add your own theme
Copy src/themes/_template.css, rename brand, set the colors for light and dark, and link it. A theme only sets the ground and accent.
:root[data-theme="brand"] {
--cu-bg: #f7f8fa;
--cu-tint: #f1f3f6;
--cu-rule: #e3e6eb;
--cu-accent: #ff6b6b;
}
@media (prefers-color-scheme: dark) {
:root[data-theme="brand"]:not([data-mode="light"]) {
--cu-bg: #23252e; --cu-surface: #2c2f3a; --cu-tint: #343744; --cu-rule: #444858;
--cu-accent: #ff6b6b;
}
}
:root[data-theme="brand"][data-mode="dark"] {
--cu-bg: #23252e; --cu-surface: #2c2f3a; --cu-tint: #343744; --cu-rule: #444858;
--cu-accent: #ff6b6b;
}Then <html data-theme="brand">. To show it in the picker, add Coverup.themes.brand = '#ff6b6b'.
Tweak without a theme file
Override tokens after the library CSS to change a single project:
:root { --cu-accent: #ff6b6b; --cu-radius: 0; --cu-offset: 4px; }Tokens
| Token | What it does |
|---|---|
--cu-bg | Page ground |
--cu-surface | Panels, inputs, buttons |
--cu-tint | Hover and header fills |
--cu-rule | Soft inner dividers |
--cu-line | Outlines |
--cu-shadow | Hard offset shadow color |
--cu-ink / -soft / -faint | Text |
--cu-accent / --cu-accent-ink | Accent and the text on it |
--cu-danger / --cu-ok | Status colors |
--cu-border | Outline width (2px) |
--cu-radius / -lg | Corner radius |
--cu-offset / -lg / -xl | Shadow distance for buttons, panels, dialogs |
--cu-font / --cu-mono | Font stacks |