Design System
Design tokens, theme presets, dark mode, and customization — the visual foundation behind every component.
Architecture
Two-layer system: raw palette scales mapped to semantic tokens.
How It Works
Two independent axes: visual theme (fonts, radius, colors) and color mode (light/dark).
Color Tokens
Semantic color tokens organized by purpose. All switch automatically in dark mode.
| Group | Token | Swatch | UC Class | Description |
|---|---|---|---|---|
| Foreground | --fg-primary | text-fg-primary | Primary text & icons | |
| Foreground | --fg-secondary | text-fg-secondary | Secondary text | |
| Foreground | --fg-tertiary | text-fg-tertiary | Tertiary / subtle text | |
| Foreground | --fg-disabled | text-fg-disabled | Disabled / placeholder | |
| Neutrals | --neutrals-background | bg-neutrals-background | Page background | |
| Neutrals | --neutrals-surface | bg-neutrals-surface | Card / panel surface | |
| Neutrals | --neutrals-subtle | bg-neutrals-subtle | Hover fills | |
| Neutrals | --neutrals-muted | bg-neutrals-muted | Secondary fills | |
| Neutrals | --neutrals-emphasis | bg-neutrals-emphasis | Stronger fills | |
| Border | --border-default | border-border-default | Standard border | |
| Border | --border-strong | border-border-strong | Prominent border | |
| Accents | --accents-blue | bg-accents-blue / text-accents-blue | Primary / Info / Focus | |
| Accents | --accents-green | bg-accents-green / text-accents-green | Success | |
| Accents | --accents-red | bg-accents-red / text-accents-red | Error / Danger | |
| Accents | --accents-orange | bg-accents-orange / text-accents-orange | Warning | |
| Tints | --tint-blue | bg-tint-blue | Info tint background | |
| Tints | --tint-green | bg-tint-green | Success tint background | |
| Tints | --tint-red | bg-tint-red | Danger tint background | |
| Tints | --tint-orange | bg-tint-orange | Warning tint background | |
| Constant | --constant-white | text-constant-white / bg-constant-white | Always white | |
| Constant | --constant-black | text-constant-black / bg-constant-black | Always black |
Spacing
Consistent spacing scale used for padding, margin, and gap.
| Key | Value | Example Classes | Preview |
|---|---|---|---|
| 0 | 0 | uc-p-0 uc-m-0 uc-gap-0 | |
| 0.5 | 0.125rem (2px) | uc-p-0.5 uc-m-0.5 uc-gap-0.5 | |
| 1 | 0.25rem (4px) | uc-p-1 uc-m-1 uc-gap-1 | |
| 1.5 | 0.375rem (6px) | uc-p-1.5 uc-m-1.5 uc-gap-1.5 | |
| 2 | 0.5rem (8px) | uc-p-2 uc-m-2 uc-gap-2 | |
| 3 | 0.75rem (12px) | uc-p-3 uc-m-3 uc-gap-3 | |
| 4 | 1rem (16px) | uc-p-4 uc-m-4 uc-gap-4 | |
| 5 | 1.25rem (20px) | uc-p-5 uc-m-5 uc-gap-5 | |
| 6 | 1.5rem (24px) | uc-p-6 uc-m-6 uc-gap-6 | |
| 8 | 2rem (32px) | uc-p-8 uc-m-8 uc-gap-8 | |
| 10 | 2.5rem (40px) | uc-p-10 uc-m-10 uc-gap-10 | |
| 12 | 3rem (48px) | uc-p-12 uc-m-12 uc-gap-12 | |
| 16 | 4rem (64px) | uc-p-16 uc-m-16 uc-gap-16 |
Typography
Font size scale with corresponding utility classes.
| Name | Size | Class | Preview |
|---|---|---|---|
| xs | 0.75rem (12px) | uc-text-xs | Aa |
| sm | 0.875rem (14px) | uc-text-sm | Aa |
| base | 1rem (16px) | uc-text-base | Aa |
| lg | 1.125rem (18px) | uc-text-lg | Aa |
| xl | 1.25rem (20px) | uc-text-xl | Aa |
| 2xl | 1.5rem (24px) | uc-text-2xl | Aa |
| 3xl | 1.875rem (30px) | uc-text-3xl | Aa |
| 4xl | 2.25rem (36px) | uc-text-4xl | Aa |
Shadows
Elevation system for layered interfaces.
Z-Index
Layering system to keep overlapping elements in the right order.
| Token | Value | Usage |
|---|---|---|
| --z-dropdown | 1000 | Dropdowns |
| --z-sticky | 1020 | Sticky headers |
| --z-fixed | 1030 | Fixed elements |
| --z-drawer | 1040 | Drawers / sheets |
| --z-modal | 1050 | Modals / dialogs |
| --z-popover | 1060 | Popovers |
| --z-tooltip | 1070 | Tooltips |
Transitions
Timing tokens for consistent animation speed.
| Token | Value | Usage |
|---|---|---|
| --transition-fast | 150ms ease | Hover / micro-interactions |
| --transition-normal | 200ms ease | Default transitions |
| --transition-slow | 300ms ease | Page / layout transitions |
Usage
Reuse ready uicraft classes and components — they already consume semantic tokens.
Utility Classes
Primary text token
Disabled text token
Ready Components
Colors/radius/typography come from active theme tokens.
<!-- Reuse ready uicraft classes/components -->
<div class="uc-card">
<div class="uc-card-header">
<span class="uc-badge uc-badge-secondary">Token-driven UI</span>
</div>
<div class="uc-card-body">
<p class="uc-text-fg-primary">Primary text token</p>
<p class="uc-text-fg-disabled">Secondary text token</p>
<button class="uc-btn uc-btn-primary">Primary Action</button>
</div>
</div>
Built-in Presets
Three theme presets ship with uicraft. Each changes fonts, radius, and subtle color shifts.
| Theme | Font Family | Radius (lg) | Character |
|---|---|---|---|
| default | Inter, system-ui, sans-serif | 12px | Clean and modern |
| editorial | Source Serif 4, Georgia, serif | 10px | Classic, editorial feel |
| rounded-sans | Manrope, Inter, sans-serif | 14px | Soft, rounded corners |
Dark Mode
Add .dark to <html> to switch all semantic tokens to their dark variants.
<!-- Toggle dark mode with JS -->
<script>
function toggleDarkMode() {
const html = document.documentElement;
html.classList.toggle('dark');
const mode = html.classList.contains('dark') ? 'dark' : 'light';
localStorage.setItem('theme', mode);
}
</script>
<!-- Restore on page load (put in <head>) -->
<script>
const mode = localStorage.getItem('theme');
if (mode === 'dark' ||
(!mode && matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
}
</script>
Switching Themes
Set data-theme on <html> and persist with localStorage.
Live Theme Controls
Mode
Theme
Live Tokens
Foreground and accents react to current theme + mode.
Semantic tokens in syncSample Component
Radius and colors update as you switch presets.
<!-- Switch theme preset -->
<script>
function setTheme(name) {
document.documentElement.setAttribute('data-theme', name);
localStorage.setItem('uicraft-theme', name);
}
// Restore on page load
const theme = localStorage.getItem('uicraft-theme') || 'default';
document.documentElement.setAttribute('data-theme', theme);
</script>
Custom Theme
Create a JSON file in themes/ to add your own preset.
themes/my-theme.jsondata-theme="my-theme"{
"name": "my-theme",
"label": "My Theme",
"fontFamily": "Poppins, system-ui, sans-serif",
"radius": {
"sm": "8px",
"lg": "12px",
"xl": "16px",
"2xl": "20px",
"3xl": "24px"
},
"colors": {
"constantWhite": "0 0% 100%",
"constantBlack": "0 0% 0%",
"fgPrimary": "240 3% 6%",
"fgSecondary": "228 4% 25%",
"neutralsBackground": "0 0% 98%",
"neutralsSurface": "0 0% 100%",
"borderDefault": "0 5% 92%",
"accentsBlue": "219 88% 54%",
...
},
"dark": { "colors": { "fgPrimary": "0 0% 98%", ... } }
}
Token Override Order
How CSS specificity works: theme preset > dark mode > component styles > utilities.
Surface Classes
Wrappers that provide consistent card-like appearance with borders, radius, and background.
<!-- Surface card -->
<div class="uc-surface-card">
<div class="uc-p-6">Content inside a surface card</div>
</div>
<!-- Table wrap -->
<div class="uc-table-wrap">
<table class="uc-table">
<thead>...</thead>
<tbody>...</tbody>
</table>
</div>
Tone Modifiers
Apply semantic coloring for info, success, warning, and danger states.
.uc-tone-info
.uc-tone-success
.uc-tone-warning
.uc-tone-danger
<!-- Tone modifiers add bg, border, and text color -->
<div class="uc-alert uc-tone-info">Info message</div>
<div class="uc-alert uc-tone-success">Success message</div>
<div class="uc-alert uc-tone-warning">Warning message</div>
<div class="uc-alert uc-tone-danger">Error message</div>
Status Indicators
Small pills and dots for showing state in tables, lists, and cards.
<div class="uc-status-pill uc-tone-success">
<span class="uc-status-dot"></span>
Active
</div>
<div class="uc-status-pill uc-tone-danger">
<span class="uc-status-dot"></span>
Offline
</div>
Component Class Reference
Quick reference of all pre-built component classes defined in the system.
| Group | Classes |
|---|---|
| Button |
.uc-btn.uc-btn-primary.uc-btn-secondary.uc-btn-bordered.uc-btn-clear.uc-btn-danger.uc-btn-link.uc-btn-sm.uc-btn-lg.uc-btn-icon
|
| Input |
.uc-input.uc-input-error.uc-textarea.uc-textarea-error.uc-label
|
| Card |
.uc-card.uc-card-header.uc-card-body.uc-card-footer
|
| Badge |
.uc-badge.uc-badge-primary.uc-badge-secondary.uc-badge-bordered.uc-badge-danger.uc-badge-success.uc-badge-warning
|
| Alert |
.uc-alert.uc-alert-info.uc-alert-success.uc-alert-warning.uc-alert-danger
|
| Avatar |
.uc-avatar.uc-avatar-sm.uc-avatar-md.uc-avatar-lg.uc-avatar-xl
|
| Tabs |
.uc-tabs-list.uc-tabs-trigger.uc-tabs-list-underline.uc-tabs-trigger-underline
|
| Separator |
.uc-separator.uc-separator-h.uc-separator-v
|
| Progress |
.uc-progress.uc-progress-bar
|
| Dialog |
.uc-dialog-overlay.uc-dialog
|
| Toast |
.uc-toast
|
| Tooltip |
.uc-tooltip
|
| Scroll |
.uc-scroll.uc-scroll-hidden.uc-scroll-autohide.uc-scroll-indicator.uc-scroll-indicator-h
|