Skip to content
Eskais UI

Theming

Theming

A handful of seed tokens derive every colour in light and dark. Palettes, density, corner radius and glass are attribute scopes you can nest anywhere.

Theme editor

Pick a preset, a brand and a link colour, tint the greys, and choose the density and the corner radius. The whole site follows, on every page and on your next visit, until you press Reset; copy the CSS when you like it.

A grey brand has no chroma, so its hue shows only once you drag right in the area.

Links and the editor caret derive from it, capped in lightness to keep 4.5:1.

0.000

Compact tightens controls, spacing and type; the radius stays yours.

Translucent, blurred chrome: popovers, menus, toasts, the sidebar and cards. Dialogs and drawers stay opaque.

Contrast (needs 4.5:1)

  • Primary foreground on primary—Fail
  • Text on background—Fail
  • Links on muted—Fail
Theme CSS
:root {  --brand: oklch(0.205 0 0);  --link-brand: oklch(0.55 0.2 260);  --neutral-hue: 0;  --neutral-chroma: 0;  --radius: 1rem;}
/* .dark derives from the same seeds.   To change one token, override it:.dark {  --primary: oklch(0.8 0.1 262);} */

Paste the CSS after the theme in your stylesheet.

Seeds

Set the seeds in :root. Primary, its foreground, ring, accent and the greys derive from them in both modes. To take over one colour, set that token in :root or .dark. Keep a custom brand at 4.5:1 on the background.

src/index.css
:root {  --brand: oklch(0.55 0.2 262);      /* primary, ring, accent */  --link-brand: oklch(0.55 0.2 262); /* links and the caret */  --neutral-hue: 262;                /* tint the greys toward the brand */  --neutral-chroma: 0.01;  --radius: 0.75rem;}
  • --primary-foreground follows --brand, near-white or near-black, and reaches at least 4.5:1 on any sRGB colour. Dark mode lightens a dark brand on its own.
  • --link-brand colours links apart from the brand. It defaults to a blue, so links keep a hue under the near-black neutral brand, and their lightness is clamped to keep 4.5:1. The palettes set it to their brand.
  • Derived colours use CSS relative colour syntax: Chrome 119, Firefox 128, Safari 18 and later. Older browsers keep the default neutral look.

Palettes

@eskais/palettes ships presets: data-palette="neutral" (the default look), "blue", "violet", "green" and "orange", on any element or through createAppearance({ palette }).

Density and radius

Two axes, each an attribute on <html> or any element, that every component follows through its tokens. Choose them apart: a compact table with square corners, a roomy page of pills.

AttributeValuesWhat it changes
data-densitydefault | compactControl heights and padding, every spacing role and the type steps. Needs the theme-compact item.
data-radiusnone | sm | md | lg | fullThe radius of controls, choices, surfaces and floating UI. Without it the shape derives from --radius (lg).
data-theme="compact"aliasCompact density with the md radius and flatter surfaces, as before the axes split. data-density or data-radius on the same element wins.
src/appearance.ts
const appearance = createAppearance({  density: "compact",  radius: "sm",  storage: {    density: createLocalStorage("density"),    radius: createLocalStorage("radius"),  },})
appearance.radius.set("full")

Both nest, so one region can differ from the page. A Sidebar takes density="compact" (a Shell, sidebarDensity) to go compact in a default page, or "default" to stay roomy in a compact one; the main content keeps the page's density. Two more knobs tighten its groups on their own: groupGap (--sidebar-group-gap, the space between groups, gap-group by default) and groupHeaderHeight (--sidebar-group-header-height, the height of a group's label or collapsible trigger). Each takes "compact" or a length, or set the property in CSS on the sidebar or any ancestor.

A compact sidebar in a default page
<Shell sidebarDensity="compact" sidebarGroupGap="compact" sidebarGroupHeaderHeight="compact" …>
/* or in CSS, on the sidebar or an ancestor */.app-sidebar {  --sidebar-group-gap: var(--gap-items);  --sidebar-group-header-height: 1.5rem;}

Compact, glass and liquid glass

ItemAttributeWhat it changes
themenoneSemantic colours, shape, density and surface tokens.
theme-compactdata-density="compact"Compact density at any width, and the data-theme="compact" alias (compact density with the md radius).
theme-glassdata-theme="glass"Translucent, blurred chrome: popovers, menus, toasts, sidebar and cards. Dialogs stay opaque.
theme-liquiddata-theme="liquid"Thick, nearly clear glass on the same chrome, with specular rims, a sheen and pill controls; secondary, outline and ghost buttons, toggles, segmented controls and tab lists turn to glass too. Dialogs stay opaque.

A theme only sets tokens, so never branch on it in a component. Nest scopes freely: a compact table inside a default page, a glass toolbar over a photo.

Tune glass live by setting --glass-opacity (and --glass-blur) on the element that has data-theme="glass" or on a descendant. The editor above turns glass on for the whole site, and its strength (40% by default: 60% opaque, a 20px blur) goes into the CSS as a [data-theme="glass"] rule. Dialogs and drawers stay opaque at any strength: a translucent fill over the dimmed backdrop reads grey. Glass falls back to solid surfaces when the browser lacks backdrop-filter or the person asks for reduced transparency.

Liquid glass keeps the same knobs (--glass-opacity, --glass-blur, --glass-saturation) and adds --glass-rim, --glass-specular and --glass-sheen. Render <LiquidLens /> once in the page and, in Chromium, menus, popovers, toasts and Floating bars bend what is behind their edges; other browsers keep the blur. It turns opaque on the same terms as glass, and data-elevation="flat" drops its rims and translucency.

Dark mode

  • createAppearance({ colorScheme: "system" }) and <Appearance> keep .dark, data-color-scheme, data-theme, data-palette, data-density and data-radius on <html> in sync. Call appearance.apply() before the first render to avoid a flash. appearance.colorScheme.set("dark") and appearance.theme.set("compact") change them, and storage: { colorScheme, theme, density, radius } (from createLocalStorage) keeps them between visits. It needs no server, so it works in a static file:// page.
  • Before any script runs, the theme follows prefers-color-scheme: dark, unless <html> has data-color-scheme="light" or class="light": render one from the server for a saved light choice.
  • The theme item ships a @custom-variant dark block that follows the same rule. Keep it below the one-line variant shadcn init writes; Tailwind uses the last one.

Elevation

Two levels: in-page surfaces (shadow-surface, rounded-surface) and floating UI (surface-floating: border, radius, translucent popover fill, shadow and backdrop). data-elevation="flat" on any ancestor drops the floating shadow, blur and translucency. See Spacing and tokens.