Customization
Zen uses CSS custom properties (variables) for all design tokens, making it easy to customize the look and feel of your application. You can override these variables to match your brand or create entirely custom themes.
Overriding variables
To customize Zen, override the CSS variables in your stylesheet. Variables defined on :root apply globally, while scoped selectors can target specific themes.
:root {
/* Override for both light and dark themes */
--font-family: 'Inter', sans-serif;
}
/* Override only in light mode */
[data-theme="light"] {
--surface-base: #fafafa;
--text-primary: #1a1a1a;
}
/* Override only in dark mode */
[data-theme="dark"] {
--surface-base: #0a0a0a;
--text-primary: #fafafa;
}Creating a branded theme
Here’s an example of creating a custom branded theme with a blue accent:
[data-theme="light"] {
/* Primary button and accent color */
--primary: oklch(0.55 0.2 250);
--primary-foreground: #ffffff;
--focus-ring: oklch(0.7 0.15 250);
}
[data-theme="dark"] {
/* Lighter primary for dark mode */
--primary: oklch(0.7 0.15 250);
--primary-foreground: oklch(0.2 0 0);
--focus-ring: var(--primary);
}CSS variable reference
Primary
The primary accent color used for primary buttons and branded elements.
| Variable | Description |
|---|---|
| --primary | Primary/brand accent color (button backgrounds) |
| --primary-foreground | Text color on primary backgrounds |
Surfaces
Background colors for different elevation levels.
| Variable | Description |
|---|---|
| --surface-base | Primary background (page level) |
| --surface-raised | Elevated surfaces (cards, modals) |
| --surface-sunken | Recessed areas (inputs, wells) |
| --surface-overlay | Overlays (dropdowns, popovers) |
| --surface-inverted | Inverted background (tooltips) |
| --surface-disabled | Disabled element background |
Text
Text colors for different emphasis levels.
| Variable | Description |
|---|---|
| --text-primary | Primary text (headings, body) |
| --text-muted | Muted text (labels, placeholders, hints) |
| --text-disabled | Disabled text |
Borders
Border colors for different emphasis levels.
| Variable | Description |
|---|---|
| --border-default | Default border (inputs, cards) |
| --border-muted | Subtle borders (dividers) |
| --border-strong | Emphasized borders (focus, active) |
Interactive states
Colors for interactive elements like buttons, checkboxes, and list items.
| Variable | Description |
|---|---|
| --interactive-bg | Default interactive background |
| --interactive-bg-hover | Hover state background |
| --interactive-bg-pressed | Pressed/active state background |
Focus
Focus ring styles for accessibility.
| Variable | Description |
|---|---|
| --focus-ring | Focus ring color |
| --focus-ring-offset | Focus ring offset color (gap) |
Status colors
Colors for feedback states (info, success, warning, error).
| Variable | Description |
|---|---|
| --status-info | Info accent color |
| --status-info-bg | Info background |
| --status-info-text | Info text color |
| --status-success | Success accent color |
| --status-success-bg | Success background |
| --status-success-text | Success text color |
| --status-warning | Warning accent color |
| --status-warning-bg | Warning background |
| --status-warning-text | Warning text color |
| --status-error | Error accent color |
| --status-error-bg | Error background |
| --status-error-text | Error text color |
Typography
Font family variables.
| Variable | Description |
|---|---|
| --font-family | Default font stack |
| --font-family-mono | Monospace font stack |
Using OKLCH colors
Zen uses OKLCH color values for better color manipulation and perceptual uniformity. OKLCH colors are defined as oklch(lightness chroma hue):
- Lightness: 0 (black) to 1 (white)
- Chroma: 0 (gray) to ~0.4 (vivid)
- Hue: 0-360 degrees (color wheel)
:root {
/* A vibrant blue */
--brand-color: oklch(0.6 0.2 250);
/* A muted green */
--subtle-green: oklch(0.7 0.1 150);
/* With transparency */
--overlay-bg: oklch(0.2 0 0 / 0.5);
}Tips
- Always provide both light and dark theme overrides for a consistent experience
- Use OKLCH for colors to maintain perceptual consistency across themes
- Test your customizations in both themes to ensure adequate contrast
- Use browser DevTools to inspect and experiment with CSS variables in real-time