Skip to content

Theme

Every colour, font, corner and spacing in Pulze comes from tokens: CSS variables in one file, config/theme.css. Change a token and every page follows, in both light and dark mode.

The theme drawer: mode, accent, layout, density and animations

How it fits together

siteConfig.theme   → what a first-time visitor sees (mode, accent, layout, density, animations)
theme drawer       → each person can change those for themselves (saved in their browser)
theme.css          → the actual colours for every mode and accent

1. Default look for new visitors

In config/site.config.ts:

theme: {
  mode: "system",        // "light" | "dark" | "system" (follows the device)
  accent: "indigo",      // "indigo" | "teal" | "rose" | "amber" | "violet" | "green"
  layout: "sidebar",     // "sidebar" | "collapsed" | "topnav"
  density: "comfortable",// "comfortable" | "compact"
  animations: true,
  allowCustomise: true,  // false hides the theme drawer and ignores saved choices
},

People's own choices are saved in their browser under the key pulze-theme. Only settings that differ from your defaults are saved. Change a default later, and everyone who never touched that setting gets the new one.

2. Change the colours

Open config/theme.css. The light values sit under :root, the dark values under .dark:

:root {
  --background: oklch(0.985 0.004 265);
  --card: oklch(1 0 0);
  --foreground: oklch(0.22 0.02 265);
  --primary: oklch(0.56 0.21 268);
  /* … */
}
.dark {
  --background: oklch(0.15 0.015 265);
  /* … */
}

Colours are written as oklch(lightness chroma hue):

  • lightness runs from 0 (black) to 1 (white);
  • chroma is the strength of the colour (0 is grey, about 0.25 is vivid);
  • hue is an angle from 0 to 360: red ≈ 25, orange ≈ 60, yellow ≈ 95, green ≈ 150, teal ≈ 190, blue ≈ 250, indigo ≈ 268, violet ≈ 300, pink ≈ 350.

To tint the whole interface towards your brand, change the last number (the hue) of the neutral tokens. To use a hex colour, paste it as it is; CSS accepts --primary: #4f46e5; too.

Every token

Token Used for
--background Page background
--sidebar Sidebar and top bar background
--card Cards, menus, dialogs
--foreground Main text
--muted-foreground Secondary text, labels, axis labels
--border Every border and divider
--primary / --primary-foreground Buttons, links, active menu items, focus rings / text on them
--primary-ink Primary used as text (text-primary-ink): links, active item
--primary-soft Tinted backgrounds: active menu item, selected rows
--chart-1 … --chart-4 Chart series, in order (--chart-1 follows the accent)
--success, --warning, --danger, --info (+ -soft) Status pills, deltas, toasts, alerts
--track Empty part of progress bars, chart grid, skeletons
--chip Segmented controls, tags, subtle fills
--radius Corner size of cards; smaller parts are derived from it
--density Spacing multiplier (1 comfortable, 0.8 compact)

In components, tokens are used as Tailwind classes: bg-card, text-muted-foreground, border-border, bg-primary-soft, text-success and so on.

Keeping text readable

Every text colour in Pulze passes WCAG AA contrast (4.5:1) in light and dark mode, for every accent; tests/a11y.spec.ts checks it. When you change colours, keep that:

  • Coloured text uses text-primary-ink, not text-primary. Most accents are dark enough for text, so --primary-ink is simply var(--primary). Amber is a light, bright fill, so its ink is a darker amber (--primary-ink: oklch(0.5 0.12 60)). Do the same for any light accent you add.
  • Status colours are text colours too. --success, --warning and --danger sit on their -soft backgrounds in pills; keep their lightness around 0.5 in light mode.
  • Check a new colour with pnpm test:e2e tests/a11y.spec.ts, or any contrast checker (paste the oklch value into the browser's colour picker to get hex).

3. Accent colours

Each accent in the theme drawer is a small block in theme.css:

[data-accent="teal"] {
  --primary: oklch(0.52 0.11 190);
  --primary-foreground: oklch(1 0 0);
  --primary-soft: oklch(0.955 0.03 190);
}
.dark[data-accent="teal"] {
  /* dark values */
}

Add your own accent:

  1. Copy a block in theme.css and rename it, e.g. [data-accent="brand"].

  2. Add it to the Accent type and the ACCENTS list in config/theme.ts:

    export type Accent = "indigo" | "teal" | … | "brand"
    { id: "brand", label: "Brand", swatch: "#ff5a1f" },
    
  3. Optionally make it the default: theme.accent: "brand".

Contrast tip: keep white text readable. Use a lightness of about 0.55 or lower for --primary in light mode. If your brand colour is light (yellow, amber), set --primary-foreground to a dark colour instead, as the amber preset does.

4. Fonts

Pulze uses Manrope for text and JetBrains Mono for code and IDs.

  • Next.js (app/layout.tsx):

    import { Inter } from "next/font/google"
    const sans = Inter({ subsets: ["latin"], variable: "--font-manrope" })
    

    Keep the variable name, or rename it in theme.css too (--font-sans: var(--font-manrope), …).

  • Vite: install the font (pnpm add @fontsource-variable/inter), import it in src/main.tsx, and set --font-manrope: "Inter Variable"; in src/index.css.

Numbers use tabular figures everywhere (font-variant-numeric: tabular-nums), so columns of numbers line up.

5. Corners and density

  • --radius: 1.125rem controls card corners. Buttons and inputs use smaller steps derived from it. Try 0.5rem for a sharper look.
  • Density changes --density. Components use the spacing utilities p-page, p-card, gap-gap and h-row, which all scale with it. Use them in your own components so they follow the setting too.

6. Dark mode details

  • The .dark class sits on <html>. Style dark-only details with Tailwind's dark: prefix, e.g. dark:border-white/10.
  • A tiny script in <head> applies the saved theme before the first paint, so dark-mode users never see a white flash. It is generated by themeInitScript() in config/theme.ts. You don't need to edit it.

7. Lock the theme

To stop people changing the look (for example, a strict brand app), set allowCustomise: false. The theme drawer disappears and saved choices are ignored. Visitors always see your defaults.