AI
NUICSS logov3.1.0

Theming & Design Tokens

NUICSS features a modern, token-first design system built on OKLCH perceptual color palettes and CSS custom properties. It functions as the single source of truth for @nofinite/nui and @nofinite/nuicss.


Why OKLCH?

Unlike legacy sRGB or HSL color spaces, OKLCH (Oklab Lightness Chroma Hue) is perceptually uniform. This means:

  1. Predictable Contrast: A lightness value of 0.6 in green has the exact same perceived brightness as 0.6 in blue or red, preventing contrast violations when customizing brand palettes.
  2. Smooth Gradients: Color interpolations stay vibrant and never pass through muddy grayish dead zones.
  3. Wide Gamut: Supports display-P3 screens natively while providing safe fallbacks for legacy browsers.

Semantic Color Tokens

NUICSS components and utility classes consume semantic variables that invert seamlessly between light and dark modes:

Semantic ClassCSS VariableLight Mode RoleDark Mode Role
bg-pagevar(--bg-page)Canvas background (neutral-50)Dark canvas (neutral-950)
bg-surfacevar(--bg-surface)Card and modal container (white)Elevated dark surface (neutral-900)
bg-subtlevar(--bg-subtle)Hover highlights and secondary tilesSubtle dark tile (neutral-800)
bg-mutedvar(--bg-muted)Inactive pills, disabled fillsMuted dark background (neutral-800)
text-defaultvar(--fg-default)High-contrast primary headings and bodyCrisp white / light gray text
text-mutedvar(--fg-muted)Secondary captions and helper notesMedium contrast text
border-defaultvar(--border-default)Structural boundaries and cardsSubtle dark borders
border-subtlevar(--border-subtle)Table cell dividers, secondary rulesLow-contrast dark dividers

Brand & Feedback Tokens

RoleBackgroundText UtilityBorder UtilityPurpose
Primarybg-primarytext-primaryborder-primaryMain brand action and active states
Successbg-successtext-successborder-successConfirmed operations, positive trends
Warningbg-warningtext-warningborder-warningNon-blocking alerts, cautionary statuses
Dangerbg-dangertext-dangerborder-dangerDestructive actions, system errors

Data Visualization & Chart Tokens

All charts in @nofinite/nui automatically read these 5 sequential theme tokens for multi-series graphs:

TokenVariablePurpose
Chart 1var(--chart-1)Primary data series / brand stroke
Chart 2var(--chart-2)Secondary series comparison
Chart 3var(--chart-3)Tertiary series
Chart 4var(--chart-4)Fourth series metric
Chart 5var(--chart-5)Fifth series / auxiliary data

Border Radius Scale

NUICSS standardizes curvature using geometric radius tokens:

Utility ClassCSS VariableComputed ValueRecommended Use
rounded-smvar(--radius-sm)4pxSmall badges, tooltips, tags
rounded-mdvar(--radius-md)8pxButtons, inputs, small cards
rounded-lgvar(--radius-lg)12pxStandard cards, modal dialogs, menus
rounded-xlvar(--radius-xl)16pxHero feature sections, large callouts
rounded-fullvar(--radius-full)9999pxAvatar circles, pill badges

Dark Mode Implementation

NUICSS applies dark mode styles by toggling the .dark class on the root <html> element:

html
<!-- Light Mode -->
<html class="light">
  <body class="bg-page text-default">...</body>
</html>

<!-- Dark Mode -->
<html class="dark">
  <body class="bg-page text-default">...</body>
</html>

Because all component superclasses (btn, card, input, table) use CSS variables for their fills and borders, toggling the root class instantly switches themes without requiring utility class duplication (e.g. bg-white dark:bg-slate-900).


Customizing Your Theme

To override any token globally, simply redefine the CSS variable in your stylesheet:

css
/* app/globals.css */
:root {
  /* Customize brand primary to a custom violet OKLCH color */
  --brand-primary: oklch(0.55 0.22 280);
  --color-primary: var(--brand-primary);
  
  /* Make standard card corners sharper */
  --radius-lg: 6px;
}
Tip

Use the Theme Studio to visually customize palettes, test contrast ratios, and export ready-to-use CSS configurations.