v1.1.8

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.

Palette (raw scales)
--grey-50 … --grey-950
--blue-50 … --blue-950
--green-50 … --green-950
--red-50 … --red-950
--orange-50 … --orange-950
Semantic Tokens
--fg-primary → grey-950
--neutrals-surface → generic-0
--accents-blue → blue-500
--border-default → grey-100
--tint-red → red-50

How It Works

Two independent axes: visual theme (fonts, radius, colors) and color mode (light/dark).

Visual Theme
data-theme="..."
Controls font family, border radius, color palette
Color Mode
class="dark"
Toggles light/dark semantic tokens

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.

--shadow-sm
Subtle shadow for inputs
--shadow
Default component shadow
--shadow-md
Medium elevation
--shadow-lg
High elevation (dropdowns)
--shadow-xl
Maximum elevation (modals)

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.

html

Utility Classes

UC

Primary text token

Disabled text token

Surface + border via semantic utility classes

Ready Components

UI
Semantic tokens in 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
Aa
Default
data-theme="default"
Aa
Editorial
data-theme="editorial"
Aa
Rounded Sans
data-theme="rounded-sans"

Dark Mode

Add .dark to <html> to switch all semantic tokens to their dark variants.

Light mode
--fg-primary → grey-950
--neutrals-background → grey-50
--neutrals-surface → white
--border-default → grey-100
Dark mode
--fg-primary → grey-50
--neutrals-background → grey-950
--neutrals-surface → black
--border-default → grey-900
html
Dark mode toggle & persistence script
<!-- 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.

html

Live Theme Controls

Mode

Theme

Live Tokens

Preview

Foreground and accents react to current theme + mode.

Semantic tokens in sync

Sample Component

Button

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.

json
1
Create a JSON file: themes/my-theme.json
2
Run the build — theme CSS is auto-generated from JSON
3
Apply with data-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.

1
Theme preset — sets font, radius, base color tokens
2
Dark mode — overrides color tokens for dark palette
3
Component classes — uc-btn, uc-card use tokens
4
Utility classes — override anything inline

Surface Classes

Wrappers that provide consistent card-like appearance with borders, radius, and background.

html
Surface Card
.uc-surface-card — bordered container with surface background
Table Wrap
.uc-table-wrap — same as surface card, with overflow hidden
<!-- 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.

html
Informational tone .uc-tone-info
Success / positive tone .uc-tone-success
Warning / caution tone .uc-tone-warning
Error / danger tone .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.

html
Active
Offline
Pending
In Review
<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