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., 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/ (slides.md,
recit., tokens.json, tokens.css, and film.). 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-, 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. in a
JSON twin), just as examples/ sets theme::
slides.md
To apply a named theme to every story in the project instead, set theme.name in recit.:
recit.config.ts
theme:selects a named palette and font pairing;colorMode("light","dark", or"system") sets the initial display mode.- Any token loaded through
theme.tokensor written intheme.colorsoverrides the named theme one token at a time. - If you prefer Récit's neutral surfaces styled purely by your own tokens, leave
theme:andtheme.nameunset, asexamples/anddeck- tokens/ slides.md examples/do out of the box.deck- tokens/ recit. config.ts
2. Set your colors
Create or edit tokens.json in W3C Design Tokens (DTCG)
format next to recit., and point theme.tokens at it:
tokens.json
recit.config.ts
When Récit loads recit., it maps tokens.json into theme (DESIGN_ in
Design tokens) and writes the corresponding --recit-* CSS variables in
oklch() (see Colors):
color.(primary "#2563eb") maps totheme.and setscolors. primary --recit-(brand oklch(0.) and546 0. 215 262.88) --recit-onfocus- ring :root. In a deck,--recit-colors links (such asbrand [consectetur adipiscing](https://on the cover slide ofexample.com) slides.md), list markers, blockquote borders, and the slide progress bar.color.maps tobackground theme.(colors. background --recit-),surface- 0 color.inktotheme.(colors. foreground --recit-text),radius.lgtotheme.radius(--recit-), andradius- lg font.bodytotheme.(fonts.sans --recit-).font- sans
To customize the deck's accent color, change color. in tokens.json — for example
from "#2563eb" to "#be123c". You can also point theme.tokens to a CSS variables sheet
(./tokens.css with --color- on :root) or override individual keys in theme.colors
inside recit. (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:
Bash
Open http:// (or pass --open or -p <port>). Verify two things on the first slide
(Lorem Ipsum):
<html>carriesdata-(frommantine- color- scheme= "light" colorMode:in"light" recit.) andconfig.ts --recit-onbrand :rootmatches yourcolor.token.primary - The
consectetur adipiscinglink, 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. in tokens.json (for instance from
"#2563eb" to "#be123c"): recit dev watches theme.tokens, reloads the deck automatically, and
updates --recit- 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
Tflips thedata-attribute onmantine- color- scheme <html>from"light"to"dark"(and pressingTagain returns it to"light"), saving your choice inlocalStorageunderrecit-theme. - Without a named theme, light-only colors in
tokens.jsonnever put dark ink on a dark slide:primaryandaccentkeep their hue (lightened automatically when needed to reach at least4.5:1contrast on dark surfaces), while surfaces and text fall back to Récit's dark palette. - To supply your own dark palette, add a root
darkgroup intokens.json(dark.,color. primary dark.,color. background dark.,color.card dark.) or setcolor.ink theme.darkinrecit.. When a named theme is active, its palette holds in both modes unlessconfig.ts theme.dark(ordark.color.*) overrides it; see Dark mode.
5. Build it
Validate the story and compile the static deck bundle:
Bash
recit validate slides.mdchecks the story schema, yourrecit.andconfig.ts tokens.jsontypes, and slide contrast rules, printing✅ slides.when everything passes.md (markdown) recit build slides.mdwrites a self-contained static site into./dist(or the directory passed to-o, --output), printing✅ Built 3 slides in ./.dist dist/embeds your resolvedindex.html --recit-theme CSS and setsbrand data-onmantine- color- scheme <html>before first paint.
Check
recit validate slides.mdexits with0errors and0warnings.- In
recit dev slides.md,--recit-onbrand <html>and the cover link color reflectcolor.inprimary tokens.json, and follow live edits totokens.json. - Pressing
Tin the browser togglesdata-onmantine- color- scheme <html>between"light"and"dark"with readable text on all three slides. recit build slides.mdproducesdist/andindex.html dist/assets/containing the resolved theme variables.
See also
- Theme overview — how
--recit-*CSS variables andsettings.work.theme - Named themes —
warm-,editorial saas-product,report, andtraitsacross decks and motion films. - Colors — every
theme.colorskey, its--recit-*CSS variable, and chart palettes. - Design tokens — full
DESIGN_synonyms forTOKEN_ MAP tokens.jsonandtokens.css. - Dark mode —
colorMode, theTshortcut, and dark-mode contrast rules. - CLI reference — options for
recit dev,recit build, andrecit validate.