Skip to content

Add a theme and its colors

Goal: pick a named theme or keep the neutral base, wire brand colors from a W3C Design Tokens (tokens.json) file into recit.config.ts, verify live updates and dark mode (T) in the deck preview, and build the static deck.

Every slide deck in Récit reads --recit-* CSS variables from @recit/theme. You can select a built-in named theme for an instant editorial or product look, load your own palette from a tokens.json (or tokens.css) file so slides and motion films share one source of truth, or combine both.

The complete working files for this guide live in examples/deck-tokens/ (slides.md, recit.config.ts, tokens.json, tokens.css, and film.story.md). For the full token tables and every configuration key, see the Theme reference pages.

1. Pick a named theme

@recit/theme ships four named themes: warm-editorial, saas-product, report, and traits (see Named themes for their palettes and type scales).

To pick a named theme for a single story, add theme: to its front matter (settings.theme in a JSON twin), just as examples/deck-tokens/film.story.md sets theme: warm-editorial:

Markdownslides.md
--- title: Lorem Ipsum Tokens description: "Three slides of plain Markdown styled from tokens.json." lang: en theme: warm-editorial ---

To apply a named theme to every story in the project instead, set theme.name in recit.config.ts:

TypeScriptrecit.config.ts
import { defineConfig } from "recit/config"; export default defineConfig({ colorMode: "light", theme: { name: "warm-editorial", tokens: "./tokens.json", }, });
  • theme: selects a named palette and font pairing; colorMode ("light", "dark", or "system") sets the initial display mode.
  • Any token loaded through theme.tokens or written in theme.colors overrides the named theme one token at a time.
  • If you prefer Récit's neutral surfaces styled purely by your own tokens, leave theme: and theme.name unset, as examples/deck-tokens/slides.md and examples/deck-tokens/recit.config.ts do out of the box.

2. Set your colors

Create or edit tokens.json in W3C Design Tokens (DTCG) format next to recit.config.ts, and point theme.tokens at it:

JSONtokens.json
{ "$description": "Lorem ipsum design tokens.", "color": { "$type": "color", "primary": { "$value": "#2563eb" }, "background": { "$value": "#ffffff" }, "ink": { "$value": "#1a1d24" } }, "radius": { "$type": "dimension", "lg": { "$value": "8px" } }, "font": { "$type": "fontFamily", "body": { "$value": ["Space Grotesk", "system-ui", "sans-serif"] } } }
TypeScriptrecit.config.ts
import { defineConfig } from "recit/config"; export default defineConfig({ metadata: { lang: "en", author: "Lorem Ipsum Studio" }, colorMode: "light", theme: { tokens: "./tokens.json", }, motion: { wordsPerSecond: 2.4 }, });

When Récit loads recit.config.ts, it maps tokens.json into theme (DESIGN_TOKEN_MAP in Design tokens) and writes the corresponding --recit-* CSS variables in oklch() (see Colors):

  • color.primary ("#2563eb") maps to theme.colors.primary and sets --recit-brand (oklch(0.546 0.215 262.88)) and --recit-focus-ring on :root. In a deck, --recit-brand colors links (such as [consectetur adipiscing](https://example.com) on the cover slide of slides.md), list markers, blockquote borders, and the slide progress bar.
  • color.background maps to theme.colors.background (--recit-surface-0), color.ink to theme.colors.foreground (--recit-text), radius.lg to theme.radius (--recit-radius-lg), and font.body to theme.fonts.sans (--recit-font-sans).

To customize the deck's accent color, change color.primary.$value in tokens.json — for example from "#2563eb" to "#be123c". You can also point theme.tokens to a CSS variables sheet (./tokens.css with --color-primary on :root) or override individual keys in theme.colors inside recit.config.ts (theme.tokens is read from recit.config only, and theme.colors wins key by key).

3. Run the deck and check the colors

Start the local preview server from the project folder:

TerminalBash
recit dev slides.md

Open http://localhost:3000 (or pass --open or -p <port>). Verify two things on the first slide (Lorem Ipsum):

  1. <html> carries data-mantine-color-scheme="light" (from colorMode: "light" in recit.config.ts) and --recit-brand on :root matches your color.primary token.
  2. The consectetur adipiscing link, the list markers on slide 2 (Sed do eiusmod), the blockquote border on slide 3, and the bottom progress bar render in that brand color.

Keep recit dev running and edit color.primary.$value in tokens.json (for instance from "#2563eb" to "#be123c"): recit dev watches theme.tokens, reloads the deck automatically, and updates --recit-brand and the computed link color in place.

4. Check the dark mode

Click inside the deck and press T to toggle between light and dark mode (press ? at any time to open the keyboard shortcuts dialog):

  • Pressing T flips the data-mantine-color-scheme attribute on <html> from "light" to "dark" (and pressing T again returns it to "light"), saving your choice in localStorage under recit-theme.
  • Without a named theme, light-only colors in tokens.json never put dark ink on a dark slide: primary and accent keep their hue (lightened automatically when needed to reach at least 4.5:1 contrast on dark surfaces), while surfaces and text fall back to Récit's dark palette.
  • To supply your own dark palette, add a root dark group in tokens.json (dark.color.primary, dark.color.background, dark.color.card, dark.color.ink) or set theme.dark in recit.config.ts. When a named theme is active, its palette holds in both modes unless theme.dark (or dark.color.*) overrides it; see Dark mode.

5. Build it

Validate the story and compile the static deck bundle:

TerminalBash
recit validate slides.md recit build slides.md
  • recit validate slides.md checks the story schema, your recit.config.ts and tokens.json types, and slide contrast rules, printing ✅ slides.md (markdown) when everything passes.
  • recit build slides.md writes a self-contained static site into ./dist (or the directory passed to -o, --output), printing ✅ Built 3 slides in ./dist. dist/index.html embeds your resolved --recit-brand theme CSS and sets data-mantine-color-scheme on <html> before first paint.

Check

  1. recit validate slides.md exits with 0 errors and 0 warnings.
  2. In recit dev slides.md, --recit-brand on <html> and the cover link color reflect color.primary in tokens.json, and follow live edits to tokens.json.
  3. Pressing T in the browser toggles data-mantine-color-scheme on <html> between "light" and "dark" with readable text on all three slides.
  4. recit build slides.md produces dist/index.html and dist/assets/ containing the resolved theme variables.

See also

  • Theme overview — how --recit-* CSS variables and settings.theme work.
  • Named themes — warm-editorial, saas-product, report, and traits across decks and motion films.
  • Colors — every theme.colors key, its --recit-* CSS variable, and chart palettes.
  • Design tokens — full DESIGN_TOKEN_MAP synonyms for tokens.json and tokens.css.
  • Dark mode — colorMode, the T shortcut, and dark-mode contrast rules.
  • CLI reference — options for recit dev, recit build, and recit validate.