Skip to main content

Batoi navigation

Batoi UIF Docs

Tokens and Theming

Use explicit Batoi UIF tokens to control interface color, typography, density, radius, and theme exports.

Version 4.0.0 Version 4 active maintenance Reviewed Nov 8, 2026 Next review Feb 8, 2027

Owner: Batoi Engineering Reviewed by: Batoi UIF Maintainers Source revision: 4eb9833

Browse Batoi UIF Documentation Tokens and Theming

Tokens and Theming

Batoi UIF themes should be driven by explicit tokens instead of one-off visual overrides.

The Theme Builder example demonstrates how a client-side tool can adjust tokens and export application-ready CSS.

Token Pipeline

Controls color radius density CSS Tokens variables and JSON Preview + Export theme.css theme.json

Core Tokens

TokenPurpose
--uif-color-primaryPrimary brand/action color
--uif-accentSupporting accent color
--uif-textMain text color
--uif-surfacePrimary surface color
--uif-radius-mdStandard card radius
--uif-space-4Standard spacing unit
--uif-font-familyFont stack

UIF 2.2.0 also provides semantic typography weights, line heights, tracking, readable content measures, responsive title sizes, and text utilities. The default stack uses system fallbacks and does not require a webfont download.

Use helpers such as uif-page-title, uif-section-title, uif-component-title, uif-label, uif-caption, and uif-prose to preserve hierarchy. Size, weight, line-height, alignment, muted-text, and semantic-color utilities are available for smaller adjustments.

Example CSS

:root {
  --uif-color-primary: #0f70b7;
  --uif-accent: #00a999;
  --uif-text: #1e293b;
  --uif-surface: #ffffff;
  --uif-radius-md: 8px;
  --uif-space-4: 1rem;
  --uif-font-family: Inter, Arial, sans-serif;
}

Default palette and scales

These values are checked against the bundled UIF 4.0.0 token stylesheet. Theme overrides can change them. An application token with a similar name is not necessarily consumed by native components.

Semantic colorTokenDefault
Primary--uif-color-primary#0e68b0
Secondary--uif-color-secondary#64748b
Success--uif-color-success#16835f
Danger--uif-color-danger#c9363e
Warning--uif-color-warning#b66a09
Info--uif-color-info#087f9c

--uif-accent defaults to the primary color. Use surface, text, and border tokens with semantic colors; do not assume white text is accessible on every custom palette. Test hover, focus, and disabled states after customization.

Typography

--uif-font-sans defaults to Inter, proxima-nova, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; --uif-font-family references it. Font names do not download fonts. --uif-font-mono defaults to "SFMono-Regular", Consolas, "Liberation Mono", monospace.

Token suffix on --uif-text-xssmmdlgxl2xl3xl4xl
rem.75.87511.1251.3751.752.253
Line-height tokenUnitless value
--uif-leading-tight1.1
--uif-leading-title1.18
--uif-leading-body1.58
--uif-leading-relaxed1.7

Weight tokens --uif-weight-regular/medium/semibold/bold are 400/500/600/700. Semantic weights select these for controls, headings, labels, and metrics. Prefer uif-page-title, uif-section-title, and uif-component-title over manually combining arbitrary weights and sizes. Page-title size uses clamp(1.85rem, 2.7vw, 2.4rem); section-title size uses clamp(1.35rem, 1.7vw, 1.7rem). Copy measure is 68ch and wide measure is 82ch.

Spacing

The native family is --uif-space-*, not --batoi-space-*.

Token suffix12345678
rem.25.5.7511.5234
px at a 16px root48121624324864

Token availability does not imply a utility exists for every number. See Utilities for supported ranges.

Breakpoints and containers

Reference tokens --uif-breakpoint-sm/md/lg are 36rem/48rem/72rem. At a 16px initial font size these correspond to 576/768/1152px. They describe reference values, not configurable media-query switches: CSS custom properties cannot be substituted into ordinary media-query conditions.

Actual component queries vary. The 12-column form grid becomes one column at a viewport width of 48rem or less, resetting its spans. Utility grids use a 40rem container query. The uif-container utility establishes that query container and currently caps width at 72rem; do not assume the --uif-container token (76rem) controls that utility. Changing a breakpoint token alone does not rewrite these CSS rules.

Guidance

  • Keep token names stable.
  • Avoid per-page color overrides where tokens are enough.
  • Preview themes against forms, cards, tables, and primary actions.
  • Export CSS and JSON when a theme needs to move between applications.

Implement Light and Dark Modes

Define both modes with the same semantic token names. Components should consume surface, text, border, brand, and status tokens without testing the current mode themselves.

:root,
[data-theme="light"] {
  color-scheme: light;
  --uif-surface: #ffffff;
  --uif-surface-elevated: #f8fafc;
  --uif-text: #1e293b;
  --uif-text-muted: #64748b;
  --uif-border: #cbd5e1;
}

[data-theme="dark"] {
  color-scheme: dark;
  --uif-surface: #101a2a;
  --uif-surface-elevated: #172235;
  --uif-text: #f1f5f9;
  --uif-text-muted: #b6c2d1;
  --uif-border: #3b4a60;
}

Use an explicit user choice when one exists and otherwise follow the operating-system preference. Persist only the mode name, not a complete token payload.

const root = document.documentElement;
const stored = localStorage.getItem('theme');
const preferred = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';

function applyTheme(theme) {
  const next = theme === 'dark' ? 'dark' : 'light';
  root.dataset.theme = next;
  root.style.colorScheme = next;
}

applyTheme(stored || preferred);

document.querySelector('[data-theme-toggle]')?.addEventListener('click', () => {
  const next = root.dataset.theme === 'dark' ? 'light' : 'dark';
  localStorage.setItem('theme', next);
  applyTheme(next);
});

Place the initial mode script in the document head when possible so the correct surface is applied before first paint. A toggle must have an accessible name and expose its current state. Verify text, links, focus indicators, controls, disabled states, alerts, tables, charts, images, and code blocks in both modes. Do not invert photographs or logos with a blanket CSS filter.

The UIF 2.3.0 examples follow this pattern: the selected mode is persisted, applied before the example renders, and paired with the appropriate light or dark UIF logo asset.