Foundation & Tokens

The design token system that powers every component — surfaces, colors, spacing, typography, and the multi-axis theme engine.

Design tokens

All values (colors, sizes, radii, shadows, spacing) are CSS custom properties defined in tokens.css. Components never use hardcoded values — they always reference a token. Override any token to adapt WebBlocks UI to your brand.

Rule: Always use tokens in your own components too. Never hardcode a color, size, or radius that could change with a theme switch.

Surfaces & text

TokenDefault (light)Usage
--wb-bg#f4f6fbPage background
--wb-surface#ffffffCards, panels, modals
--wb-surface-2#edf1f7Subtle backgrounds, table rows
--wb-surface-3#e2e8f2Hover states, dividers
--wb-text#18212fPrimary text
--wb-muted#5a6a84Secondary text, labels, placeholders
--wb-border#d6e0eeAll borders and dividers

Semantic colors

TokenVariantsUsage
--wb-success-dark · -softSuccess alerts, badges, icons
--wb-warning-dark · -softWarning alerts, caution states
--wb-danger-dark · -softError states, destructive actions
--wb-info-dark · -softInformational alerts, hints

Spacing scale (4px base)

TokenValueTokenValue
--wb-s14px--wb-s832px
--wb-s28px--wb-s1040px
--wb-s312px--wb-s1248px
--wb-s416px--wb-s1664px
--wb-s520px--wb-s2080px
--wb-s624px

Border radius

TokenValue
--wb-r-sm5px
--wb-r-md9px
--wb-r-lg14px
--wb-r-xl20px
--wb-r-full9999px (pill/circle)

Typography

TokenDescription
--wb-fontBody font stack (Inter, system-ui fallbacks)
--wb-font-headingHeading font stack (same as body by default)
--wb-font-monoMonospace stack (Cascadia Code, Menlo, Consolas)
--wb-font-size-xs/sm/md/lg/xl0.75 / 0.875 / 1 / 1.125 / 1.25 rem

Shadows

TokenUsage
--wb-shadow-smSubtle lift (cards, inputs)
--wb-shadow-mdDropdowns, popovers
--wb-shadow-lgModals, drawers
--wb-shadow-xlCommand palette, elevated overlays

Z-index scale

TokenValueUsage
--wb-z-dropdown100Dropdowns, popovers, tooltips
--wb-z-modal200Modals, drawers, confirmation dialogs
--wb-z-toast300Toast notifications

Overriding tokens

Override any token in your own CSS by targeting :root or a scoped selector:

/* Global override */
:root {
  --wb-font: 'Geist', sans-serif;
  --wb-r-md: 12px;
}

/* Scoped override — only affects one section */
.my-hero {
  --wb-accent: #8b5cf6;
}

Accent colors

Set data-accent on the <html> element to switch the entire UI to a different color scheme. Each accent defines 12 tokens.

ocean
forest
sunset
royal
mint
amber
rose
slate-fire

Click a swatch above to preview the accent on this page.

Accent token set (12 tokens per accent)

TokenUsage
--wb-accentPrimary accent — button backgrounds, active states
--wb-accent-hoverHover state for accent-colored elements
--wb-accent-activeActive / pressed state
--wb-accent-softTinted background (badges, chips)
--wb-accent-softerVery light tint (page sections, callouts)
--wb-accent-borderAccent-tinted border
--wb-accent-textAccent text on light background
--wb-accent-onText color on accent background (always white or near-white)
--wb-accent-ringFocus ring color
--wb-accent-ring-rgbRGB values for rgba() focus ring with opacity
--wb-accent-selectionText selection background
--wb-accent-glow-rgbRGB values for glow effects
Backward compatibility: --wb-primary, --wb-primary-dark, and --wb-primary-soft are aliases that map to their --wb-accent* equivalents. In new code, always use --wb-accent*.

Dark mode

Dark mode is controlled by the data-mode attribute on <html>. Three values are supported.

ValueBehaviour
lightAlways light mode
darkAlways dark mode
autoFollows prefers-color-scheme system setting

How dark mode works

Dark mode overrides surface, text, and border tokens via a [data-mode="dark"] selector in dark.css. All component styles automatically inherit the new values — there are no separate dark-mode class variants needed.

<!-- Static -->
<html data-mode="dark">

<!-- Toggled by the user -->
<button data-wb-mode-cycle>Toggle mode</button>

<!-- Set programmatically -->
<script>WBTheme.setMode('dark');</script>
localStorage persistence: WBTheme persists the user's mode preference in localStorage under the key wb-mode and restores it on next page load. Set the initial data-mode in HTML to avoid a flash of the wrong mode.

Presets

Presets are named bundles that set multiple axes at once — radius, shadow, density, font, and border. Use them as starting points for a consistent look; individual axes can still override any preset value.

PresetRadiusShadowDensityFontBorder
moderndefaultdefaultdefaultmodernsubtle
minimalsharpflatcompactsystemsubtle
roundedsoftsoftcomfortablemodernnone
boldsharpdefaultdefaultmodernbold
editorialsharpflatcomfortableeditorialmedium
<!-- Apply "rounded" preset, override accent only -->
<html data-preset="rounded" data-accent="rose">

<!-- Apply "minimal", override radius to soft -->
<html data-preset="minimal" data-radius="soft">

Presets are applied in CSS cascade order before individual axis attributes, so individual axes always win.

Theme axes

Beyond dark mode and accent, five additional axes let you tune the visual personality of your UI.

Radius — data-radius

ValueEffect
sharpReduces all border radii — more structured, enterprise feel
softIncreases all border radii — friendly, consumer-facing feel

Density — data-density

ValueEffect
compactReduces padding across buttons, inputs, table rows — more content per screen
comfortableIncreases padding — more breathing room, better for touch

Shadow — data-shadow

ValueEffect
flatRemoves shadows — border-based depth, clean and minimal
softIncreases shadow blur and opacity — more elevated, premium feel

Font — data-font

ValueFont stack
systemNative OS font stack — no web font loaded
modernInter (CDN) — clean, highly legible
editorialPlayfair Display (CDN) + Inter — editorial, publishing feel

Border — data-border

ValueEffect
noneRemoves borders — surfaces defined by shadows only
subtleLight borders (default)
mediumMedium-weight borders
boldHeavy borders — strong visual structure
dashedDashed borders — distinctive, technical feel

Combining all axes

<!-- Maximum customisation without a single line of custom CSS -->
<html
  data-mode="dark"
  data-accent="royal"
  data-preset="rounded"
  data-density="comfortable"
  data-font="modern"
>

Custom token overrides

For brand-specific customization that goes beyond the built-in axes, override tokens directly in your own CSS.

/* ── Brand font ──────────────────────────────────── */
:root {
  --wb-font:         'DM Sans', sans-serif;
  --wb-font-heading: 'DM Serif Display', serif;
}

/* ── Custom accent (outside the 8 built-ins) ─────── */
:root {
  --wb-accent:           #0f766e;
  --wb-accent-hover:     #0d6e66;
  --wb-accent-active:    #0b605a;
  --wb-accent-soft:      #ccfbf1;
  --wb-accent-softer:    #f0fdf4;
  --wb-accent-border:    #5eead4;
  --wb-accent-text:      #0d6e66;
  --wb-accent-on:        #ffffff;
  --wb-accent-ring:      rgb(15 118 110);
  --wb-accent-ring-rgb:  15 118 110;
  --wb-accent-selection: #ccfbf1;
  --wb-accent-glow-rgb:  15 118 110;
}

/* ── Tighter spacing for a dense data grid ───────── */
.my-data-table {
  --wb-s3: 0.5rem;
  --wb-s4: 0.75rem;
}