Design Tokens
Three-layer token architecture: Primitives → Semantics → CSS Variables. All color values are currently in HEX and will be migrated to the OKLCH color space for perceptual uniformity.

Overview
The token system uses a three-layer architecture. Primitivesdefine raw color palettes—22 hue ramps with 9 stops each (100–900), plus alpha and absolute channels. Semantic tokens map primitives to UI roles grouped as surface, content, and border. Components reference semantic tokens, never raw primitives. Light and dark modes use mirrored primitive palettes (100 ↔ 900) so semantic mappings stay identical.
Why OKLCH
OKLCH (Oklab Lightness–Chroma–Hue) is a perceptually uniform color space. Two colors with the same lightness value look equally bright to the human eye, eliminating the uneven contrast jumps common in HSL ramps. Each shade step carries predictable contrast, accessible pairings are easier to verify, and new theme hues can be generated by rotating the hue channel while preserving the same lightness–chroma curve.
All primitives below are currently defined in HEX and will be progressively converted to OKLCH. A HEX fallback will be provided for browsers that don't support oklch():
.element {
/* Fallback for older browsers */
background: #006AFF;
/* OKLCH for modern browsers */
background: oklch(0.55 0.24 264);
}ThemeProvider
Wrap your application with ThemeProvider to enable theming. It injects all color tokens and static tokens as CSS custom properties.
import { ThemeProvider } from "madagent";
import "madagent/styles";
function App() {
return (
<ThemeProvider theme="blue" mode="light">
{/* All components have access to theme tokens */}
</ThemeProvider>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
theme | ThemeName | "blue" | The color theme to apply. One of: "blue", "red", "orange", "yellow", "green", "teal", "cyan", "sky", "deepblue", "indigo", "violet", "magenta", "fuchia", "blush", "navy", "sienna", "gold", "pink", "charm". |
mode | "light""dark" | "light" | The color mode. |
children* | ReactNode | - | Your application content. |
The provider renders a div with data-md-theme and data-md-mode attributes, which you can use for mode-specific CSS overrides.
useTheme Hook
Access the current theme and switch themes at runtime:
import { useTheme, themes } from "madagent";
function ThemeToggle() {
const { theme, setTheme } = useTheme();
const isDark = theme.mode === "dark";
return (
<button onClick={() =>
setTheme(isDark ? themes.blue("light") : themes.blue("dark"))
}>
Switch to {isDark ? "light" : "dark"} mode
</button>
);
}Primitives
Raw color palettes with 9 stops each (100–900). In light mode, 100 is the lightest and 900 the darkest. In dark mode, the ramp is inverted. Values are currently HEX and will be converted to OKLCH.
Neutral
| light | dark | token | css variable |
|---|---|---|---|
Red
| light | dark | token | css variable |
|---|---|---|---|
Orange
| light | dark | token | css variable |
|---|---|---|---|
Yellow
| light | dark | token | css variable |
|---|---|---|---|
Green
| light | dark | token | css variable |
|---|---|---|---|
Teal
| light | dark | token | css variable |
|---|---|---|---|
Cyan
| light | dark | token | css variable |
|---|---|---|---|
Sky
| light | dark | token | css variable |
|---|---|---|---|
Blue
| light | dark | token | css variable |
|---|---|---|---|
Deep Blue
| light | dark | token | css variable |
|---|---|---|---|
Indigo
| light | dark | token | css variable |
|---|---|---|---|
Violet
| light | dark | token | css variable |
|---|---|---|---|
Magenta
| light | dark | token | css variable |
|---|---|---|---|
Fuchia
| light | dark | token | css variable |
|---|---|---|---|
Blush
| light | dark | token | css variable |
|---|---|---|---|
Navy
| light | dark | token | css variable |
|---|---|---|---|
Sienna
| light | dark | token | css variable |
|---|---|---|---|
Gold
| light | dark | token | css variable |
|---|---|---|---|
Pink
| light | dark | token | css variable |
|---|---|---|---|
Charm
| light | dark | token | css variable |
|---|---|---|---|
Alpha
| light | dark | token | css variable |
|---|---|---|---|
Absolute
| light | dark | token | css variable |
|---|---|---|---|
Semantic Tokens
Semantic tokens map primitives to UI roles. Components consume these instead of referencing primitives directly. Grouped into three categories: surface (backgrounds), content (text/icons), and border (strokes/dividers).
Surface
Colors for backgrounds and fills. Use var(--md-surface-*) in CSS.
| light | dark | token | css variable |
|---|---|---|---|
Content
Colors for text and icons. Use var(--md-content-*) in CSS.
| light | dark | token | css variable |
|---|---|---|---|
Border
Colors for strokes and dividers. Use var(--md-border-*) in CSS.
| light | dark | token | css variable |
|---|---|---|---|
Spacing
Spacing tokens are not theme-dependent. Available as --md-spacing-* CSS custom properties.
| Token | CSS Variable | Value |
|---|---|---|
Typography
Font Families
| Token | CSS Variable | Value |
|---|---|---|
Font Sizes
| Token | CSS Variable | Value |
|---|---|---|
Font Weights
| Token | CSS Variable | Value |
|---|---|---|
Line Heights
| Token | CSS Variable | Value |
|---|---|---|
Borders & Radii
Border Widths
| Token | CSS Variable | Value |
|---|---|---|
Border Radii
| Token | CSS Variable | Value |
|---|---|---|
Shadows
| Token | CSS Variable | Value |
|---|---|---|