PeakUI

Theming

PeakUI is themed with CSS custom properties. Override a token and every component that uses it follows.

PeakUI has no theme object and no provider. A theme is a set of CSS custom properties, and the components read them through Tailwind utilities such as bg-accent and rounded-field.

How It Works

The stylesheet you import has three layers that matter for theming:

  1. Theme values – custom properties such as --accent, --surface and --radius, declared for the light and the dark theme.
  2. Tailwind tokens – an @theme inline block that maps each value to a Tailwind token: --color-accent: var(--accent). This is what makes bg-accent, text-muted or shadow-surface available as utilities.
  3. Component styles – BEM classes that use those utilities and expose their own variables, such as --button-bg.

Because the mapping is inline, a utility carries the raw token itself — bg-accent emits background-color: var(--accent) — so it follows the token wherever the token is set. Component styles go one step further, through the mapped custom property (--button-bg: var(--color-accent)), and that mapping is resolved once, on the root element where it is declared. An --accent set deeper in the tree never reaches it: utilities inside the subtree recolour, component palettes do not.

Override tokens on the root — :root, <html>, or your app's host element. A subtree override recolours only the utilities inside it and is not a supported way to theme a region.

Override Tokens

Declare your values after the two imports:

globals.css
@import "tailwindcss";
@import "@peakui/styles";

:root {
  /*
   * The accent is a family, not one value: hover, the soft tints and the focus
   * ring are calibrated to the default hue and keep it if left behind.
   */
  --accent: oklch(0.6 0.2 250);
  --accent-foreground: oklch(0.98 0.02 250);
  --accent-hover: oklch(0.638 0.182 250);
  --accent-soft: oklch(0.6 0.2 250 / 0.15);
  --accent-soft-foreground: oklch(0.483 0.142 251);
  --accent-soft-hover: oklch(0.6 0.2 250 / 0.2);
  --focus: oklch(0.6 0.2 250);
  --radius: 0.75rem;
}

The library's values live in a cascade layer, so a plain rule in your stylesheet always wins over them.

To try values against a whole page before writing any of this, use the Theme Builder: it reports the contrast of each pair it changes and exports the CSS it shows.

Colors

Colors are semantic: each role carries a background value and a -foreground value readable on it. Every role, drawn as a plate from its own token, is on the Colors page.

Radius

The whole radius scale is derived from one value:

:root {
  --radius: 0.5rem; /* rounded-lg; every other step is a multiple of it */
  --field-radius: 0.75rem; /* rounded-field, used by inputs */
}

Typography

:root {
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

--sans and --mono feed Tailwind's font-sans and font-mono. PeakUI does not load any font files; load the typeface yourself and name it here.

Other knobs

TokenDefaultPurpose
--border-width1pxBorder width of bordered components
--field-border-width0pxBorder width of form fields
--disabled-opacity0.5Opacity of disabled controls
--cursor-interactivepointerCursor over interactive controls
--cursor-disablednot-allowedCursor over disabled controls
--ring-offset-width2pxGap between a control and its focus ring

Customize Components

Components expose their own variables, so you can restyle one variant without touching the theme:

@layer components {
  .button--primary {
    --button-bg: var(--color-success);
    --button-bg-hover: var(--color-success-hover);
    --button-fg: var(--color-success-foreground);
  }

  .button {
    --button-radius: var(--radius-lg);
  }
}

Each component page lists its classes and variables under Styling Reference.

Import Strategies

@peakui/styles imports everything. To pick the parts yourself, import them separately, in this order:

@import "tailwindcss";

@import "@peakui/styles/themes/default";
@import "@peakui/styles/base" layer(base);
@import "@peakui/styles/utilities";
@import "@peakui/styles/variants";

/* Only the components you use */
@import "@peakui/styles/components/button.css" layer(components);
@import "@peakui/styles/components/spinner.css" layer(components);

Using the tokens in your own code

Every token is a Tailwind utility, so your own markup can stay consistent with the components:

<div className="rounded-xl bg-surface p-4 text-surface-foreground shadow-surface">
  <p className="text-muted">Secondary text</p>
</div>

On this page