PaneUI

Theming

Change the theme tokens.

How the system works

The theme has two layers. Values are CSS variables in globals.css, named for what a colour is for, such as --card. Utilities map each variable to a class in @theme inline, so --card becomes bg-card. Components use only the utilities, so changing a value restyles every component without touching its file.

VariableUtilityRead by
--backgroundoklch(100% 0 0)bg-backgroundPage canvas
--primaryoklch(10% 0 0)bg-primary text-primary-foregroundFilled buttons, switches, checks, selection
--borderoklch(10% 0 0 / 0.08)border-borderEvery divider and edge
--radius0.625rem / 1remrounded-sm … rounded-3xlAll corners (circular / squircle)
--shadow-defaulthairline + 1px dropshadow-raisedResting cards and controls
--text-ui0.8125remtext-uiButtons, inputs, menus, nav

Dark mode works the same way. .dark on <html> points the same variables at dark values, so a component written once is right in both modes. The accent is ten of those variables, --primary to --selection, which a preset swaps together.

  1. Map each mode
    Put light values on :root and dark values on .dark, under the same names.
  2. Use semantic utilities
    Write bg-card or text-muted-foreground, never palette colours or hex.
  3. Keep it central
    Skip dark: colour overrides in components, so a theme change stays one edit in one file.

The same file also holds these tokens.

  • --radiusOne base that every corner multiplies, so nested corners stay concentric.
  • text-ui-*The type scale for text inside components.
  • --shadow-*Four shadow levels behind shadow-xs to shadow-xl and the named elevation.
  • --font-*The UI, code and reading font stacks.
  • --shellColours for app chrome around the content panel.
  • --scrollbarScrollbar thumb colours.
pnpm dlx shadcn@latest add @paneui/theme

@paneui/theme writes the variables below and installs @paneui/utils, whose cn() merges the text-ui-* sizes as font sizes. For a tinted wash, use the -subtle token, such as bg-success-subtle.

globals.css (excerpt)
css

Colors

Colours are named by role, and each surface has a matching -foreground token for text on it. Use tokens in components, never palette colours (bg-zinc-100) or hex values.

Solids are for fills. For coloured text and icons use the -text role, such as text-primary-text or text-destructive-text: it reaches 4.5:1 on the page and on its -subtle wash in both modes. Labels and highlights take the tag-* colours.

  • background
  • card
  • surface-sunken
  • surface-standout
  • primary
  • primary-subtle
  • primary-text
  • fill-hover
  • muted-foreground
  • fg-tertiary
  • border
  • border-strong
  • border-control
  • ring
  • destructive
  • success
  • warning
  • info
  • tag-blue-fill
  • chart-1…8
  • shell

Dark mode

Put .dark on <html> to switch every token. The theme declares the variant as @custom-variant dark (&:is(.dark *)). Set color-scheme at the same time so native scrollbars and form controls follow. Pair primary with text-primary-foreground, never text-white, because the neutral preset makes it near-white in dark mode.

theme-script.js
js

To let users switch, use Theme Toggle, which stores the choice for the script above.

Accent presets

The accent is ten role variables per mode, neutral by default: primary and its -hover, -active, -foreground, -subtle, -subtle-hover, -border and -text variants, plus ring and selection. Every preset meets the same contrast: 4.5:1 for the label on the solid and for primary-text, 3:1 for the ring. Surfaces, text and charts stay the same. Install one after the theme.

  • theme-neutraldefault
  • theme-blue
  • theme-green
  • theme-orange
  • theme-rose
  • theme-violet
pnpm dlx shadcn@latest add @paneui/theme-violet

An installed preset overwrites the variables on :root and .dark, so the accent is fixed. To let users switch, keep the default roles on :root, add one block per accent keyed on an attribute, and apply the saved choice in the same pre-paint script as dark mode.

Switch preset accents directly from the site header, or pick a preset or custom brand colour below to copy its ten role overrides.

light
dark
lightdarksolidhoveractiveforegroundsubtlesubtle-hoverbordertextringselection
Selected
Focus ring
Link

Paste these overrides after the theme variables to keep this accent in your project.

globals.css
css
globals.css
css

Typography

Use the text-ui* sizes inside components, and keep text-sm to text-2xl for reading copy and page headings. Set titles in font-semibold, labels and buttons in font-medium, and use font-semimedium (450) where 400 reads too light on a dense row.

ClassSizeUse for
text-ui-2xs10pxTiny counters and labels.
text-ui-xs11pxMeta text, shortcuts and counts.
text-ui-sm12pxCaptions, badges, small controls, tooltips.
text-ui13pxThe default for controls, menus and text inside components.
text-ui-lg14pxLarge controls and card titles.

Fonts

--font-sans uses the OS system UI stack directly. --font-mono and --font-serif name self-hosted faces with CJK and system fallbacks, so installing the font files is optional.

UtilityFaceUse for
font-sansSystem UIAll UI text (OS native sans and CJK).
font-monoJetBrains MonoCode, keys, terminals and tabular IDs.
font-serifNewsreader, Noto Serif SCLong-form reading (the reading typeset preset).
pnpm dlx shadcn@latest add @paneui/fonts

This adds the font packages and packages/tokens/styles/fonts.css; import that file once in your root layout. Each face is split by unicode range, so a page downloads only the glyph sets it shows. For code that lines up with Chinese text, install a CJK-aligned monospace such as Sarasa Gothic or Maple Mono yourself and put it first in --font-mono.

Radius

Every step is a multiple of --radius (0.625rem / 10px in circular arc mode, capped at --radius-max = 1.375rem / 22px). Where the browser supports corner-shape: squircle, continuous superellipse corners scale --radius to 1rem (cap 2.2rem / 35.2px) because a squircle reads tighter than a circular arc. Keep nested corners concentric, with the inner radius equal to the outer radius minus the padding between them: that is why p-1 menus use frame-lg and rounded-inner (6px circular / 12px squircle) on rows, and compact controls clamp through rounded-control-md and rounded-control-sm. Use rounded-full only for shapes that are actually round.

PreviewClassSizeUse for
rounded-xs2.5px / 4pxSearch highlights, favicons and tiny segments.
rounded-sm6px / 9.6pxSmall chips and keys.
rounded-md8px / 12.8pxTooltips and compact rows.
rounded-lg10px / 16pxControls, inputs and p-1 popup menus.
rounded-xl14px / 22.4pxCards, tables and code blocks.
rounded-2xl18px / 28.8pxIcon tiles and two-layer inset cards.
rounded-3xl22px / 35.2pxDialogs, drawers and big panels.
rounded-4xl22px / 35.2pxKept for older code; sits at the cap.
rounded-5xl22px / 35.2pxKept for older code; sits at the cap.

Elevation

Four shadow levels back Tailwind's shadow-xs to shadow-xl, so plain utilities pick them up. Give resting cards, tables and code blocks shadow-raised, never a floating level. Show hover on rows, menu items and ghost buttons with a fill (bg-secondary), not a ring.

PreviewClassTokenUse for
shadow-xs--shadow-borderA 1px ring, no lift.
shadow-sm--shadow-defaultResting controls and cards.
shadow-lg--shadow-lgMenus, popovers and floating panels (shadow-md is the same).
shadow-xl--shadow-xlDialogs, drawers and sheets.

Components read these named levels, each built on the scale above.

PreviewClassUse for
shadow-raisedResting controls and cards (reads shadow-sm). Hover steps to shadow-raised-hover.
shadow-surfacePopovers, menus and floating panels (reads shadow-lg).
shadow-wellInset hairline for fields and tracks.
shadow-chipKeys and small chips.
shadow-primaryFilled primary buttons (none in dark).

Native style rules

Follow these rules when you build a new component.

  • secondary, muted and accent are fills; use bg-card, bg-popover or bg-background for anything that must be opaque.
  • No gradient sheens, inset highlights, text shadows or glows.
  • Size buttons and inputs at h-8 (sm h-7, xs h-6) and menu rows at 26px. Show disabled with opacity-64.
  • Answer a press on standard controls with a fill change, not a scale. Popups enter from scale-98 and opacity.
  • Show focus with focus-visible:ring-2 focus-visible:ring-ring.
  • Put app chrome on bg-shell and the content in a shell-inset panel.

Adding tokens

Define a new token with a value for both modes, then map it in @theme inline to get the utilities.

globals.css
css