Theming
A theme is the whole look in one CSS file. Pick a preset or bring your own, and every component and code block follows it.
A theme is the whole look of a site in one CSS file: colours, radius, fonts, shadows and code colours, for light and dark. Every component reads those tokens and nothing else, so changing the theme restyles the whole site, code blocks included, without touching a component.
Choosing a theme
The theme is chosen where the rest of the site is configured, in docsmith():
theme takes a preset name or a path to a theme file of your own. Leave it out
and you get Darkmatter, a near-monochrome shell with a warm orange primary.
Your stylesheet stays the same whatever the theme is:
theme.css makes Tailwind scan the package, registers the tokens and pulls in
the typography and animation plugins. The plugin adds the theme’s values to it,
so every page that imports it is themed, with no flash on first paint.
The presets
Eleven presets ship in the box. Pick one to apply it across this site, then toggle dark mode to see both sides:
docsmith({ theme: 'darkmatter' }) · Customise it in the builder
Available: darkmatter, tangerine, amethyst, graphite, evergreen, rose, ocean, nord, claude, bubblegum, and mono. Each one sets
colours, radius, code colours and, where its look calls for it, shadows, for
both colour modes. To start your own theme from one, open it in the theme builder.
Your own theme
A theme file is plain CSS: a :root block for light and a .dark block for
dark, setting the tokens below. Point theme at it, relative to the Vite root:
It’s the same shape tweakcn and shadcn export, so a
theme built there works as it is: paste the export into the file. Its @theme inline block is ignored, since theme.css already does that job.
Set every colour token (the table below lists them): colours have
no default, so a missing one leaves its surface unpainted. Anything else the
file leaves out keeps its default: radius, fonts, shadows and spacing fall back
to theme.css, and code colours are mixed from the theme’s palette. vite dev picks up every edit to the file without a restart.
Load fonts yourself
A theme can name font families, but it can’t load them: an @import in a theme
file is left out, with a warning. Load the font in app.css or app.html as
you normally would, and set the family in the theme.
Build a theme
The theme builder makes a theme file without writing CSS. Start from a preset, your brand colour or a tweakcn export, adjust it with a few guided controls or token by token, and watch a real docs page follow, in light and dark side by side. It warns about any text and surface pair below WCAG AA contrast.
When it looks right, take it to your project. The quickest way is to run this from your docs app:
It opens the builder in your browser. Press Send to my project there and the
command writes the theme to src/theme.css and sets theme: './src/theme.css' in the docsmith() call in vite.config.ts. A running vite dev picks it up
straight away. If it can’t find that call, it still writes the file and tells you
the line to add. Nothing leaves your machine: the browser sends the theme straight
to the command, which listens on 127.0.0.1 only and accepts one send, from the
tab it opened.
If the browser can’t reach the terminal, because the command runs in a container or over SSH, the builder shows a short code under Didn’t arrive?. Paste it at the command’s prompt instead.
| Option | What it does |
|---|---|
--link <url> | Write the theme a theme link carries, without the browser. |
--file <path> | Where to write the theme file. Default src/theme.css. |
--config <file> | The vite config to update. Default vite.config.* here. |
--builder <url> | The builder to open. Default the one on this site. |
--no-open | Print the builder link instead of opening a browser. |
You can also skip the command: the builder’s Export tab copies or downloads the
theme file, for the theme option as in Your own theme.
Theme links
Copy theme link in the Export tab gives a link that reopens the builder on
exactly that theme, to share with a teammate or come back to later. Run npx svelte-docsmith theme --link '<link>' to write the theme a link carries
straight into a project.
Overriding tokens
To adjust one or two tokens without writing a theme, redefine them in app.css.
Your value always wins over the theme, whatever order the imports are in:
A token set under :root covers light mode and anything dark mode doesn’t set
itself, so set colours under both selectors to change both modes.
The tokens
The full set, with Darkmatter’s light values or the fallback theme.css gives
when a theme leaves a token out:
Surfaces and text
Each surface comes with a -foreground for the text on it.
| Token | Default (Darkmatter, light) |
|---|---|
| --background | oklch(1 0 0) |
| --foreground | oklch(0.2101 0.0318 264.6645) |
| --card | oklch(1 0 0) |
| --card-foreground | oklch(0.2101 0.0318 264.6645) |
| --popover | oklch(1 0 0) |
| --popover-foreground | oklch(0.2101 0.0318 264.6645) |
| --primary | oklch(0.6716 0.1368 48.513) |
| --primary-foreground | oklch(1 0 0) |
| --secondary | oklch(0.536 0.0398 196.028) |
| --secondary-foreground | oklch(1 0 0) |
| --muted | oklch(0.967 0.0029 264.5419) |
| --muted-foreground | oklch(0.551 0.0234 264.3637) |
| --accent | oklch(0.9491 0 0) |
| --accent-foreground | oklch(0.2101 0.0318 264.6645) |
| --border | oklch(0.9276 0.0058 264.5313) |
| --input | oklch(0.9276 0.0058 264.5313) |
| --ring | oklch(0.6716 0.1368 48.513) |
| --destructive | oklch(0.6368 0.2078 25.3313) |
| --destructive-foreground | oklch(0.9851 0 0) |
Sidebar
The docs sidebar, tokened separately.
| Token | Default (Darkmatter, light) |
|---|---|
| --sidebar | oklch(0.967 0.0029 264.5419) |
| --sidebar-foreground | oklch(0.2101 0.0318 264.6645) |
| --sidebar-primary | oklch(0.6716 0.1368 48.513) |
| --sidebar-primary-foreground | oklch(1 0 0) |
| --sidebar-accent | oklch(1 0 0) |
| --sidebar-accent-foreground | oklch(0.2101 0.0318 264.6645) |
| --sidebar-border | oklch(0.9276 0.0058 264.5313) |
| --sidebar-ring | oklch(0.6716 0.1368 48.513) |
Charts
A five-colour series for charts and diagrams.
| Token | Default (Darkmatter, light) |
|---|---|
| --chart-1 | oklch(0.594 0.0443 196.0233) |
| --chart-2 | oklch(0.7214 0.1337 49.9802) |
| --chart-3 | oklch(0.8721 0.0864 68.5474) |
| --chart-4 | oklch(0.6268 0 0) |
| --chart-5 | oklch(0.683 0 0) |
Code
Syntax colours for every code block, unless codeTheme names a Shiki pair.
| Token | Default (Darkmatter, light) |
|---|---|
| --code-token-keyword | oklch(0.55 0.137 48.5) |
| --code-token-string | oklch(0.55 0.09 196) |
| --code-token-function | oklch(0.55 0.09 264.7) |
| --code-token-constant | oklch(0.55 0.137 120) |
| --code-token-parameter | oklch(0.55 0.137 335) |
| --code-token-comment | oklch(0.551 0.023 264.4) |
| --code-token-string-expression | var(--code-token-string) |
| --code-token-punctuation | var(--code-token-comment) |
| --code-foreground | var(--foreground) |
| --code-background | var(--muted) |
| --code-token-link | var(--primary) |
Shape and type
Corners, fonts, shadows and spacing.
| Token | Default (Darkmatter, light) |
|---|---|
| --radius | 0.75rem |
| --shadow-2xs | 0px 1px 4px 0px hsl(0 0% 0% / 0.03) |
| --shadow-xs | 0px 1px 4px 0px hsl(0 0% 0% / 0.03) |
| --shadow-sm | 0px 1px 4px 0px hsl(0 0% 0% / 0.05), 0px 1px 2px -1px hsl(0 0% 0% / 0.05) |
| --shadow | 0px 1px 4px 0px hsl(0 0% 0% / 0.05), 0px 1px 2px -1px hsl(0 0% 0% / 0.05) |
| --shadow-md | 0px 1px 4px 0px hsl(0 0% 0% / 0.05), 0px 2px 4px -1px hsl(0 0% 0% / 0.05) |
| --shadow-lg | 0px 1px 4px 0px hsl(0 0% 0% / 0.05), 0px 4px 6px -1px hsl(0 0% 0% / 0.05) |
| --shadow-xl | 0px 1px 4px 0px hsl(0 0% 0% / 0.05), 0px 8px 10px -1px hsl(0 0% 0% / 0.05) |
| --shadow-2xl | 0px 1px 4px 0px hsl(0 0% 0% / 0.12) |
| --font-sans | 'Inter Variable', Inter, sans-serif |
| --font-serif | 'Source Serif 4 Variable', 'Source Serif 4', serif |
| --font-mono | 'JetBrains Mono', ui-monospace, monospace |
| --shadow-color | hsl(0 0% 0%) |
| --shadow-opacity | 0.1 |
| --shadow-blur | 3px |
| --shadow-spread | 0px |
| --shadow-offset-x | 0px |
| --shadow-offset-y | 1px |
| --tracking-normal | 0em |
| --spacing | 0.25rem |
For agents
An agent can make a theme without the builder. Write a theme file: a :root block and a .dark block, setting the colour tokens above as oklch() values,
plus any of the others. Save it as src/theme.css and set theme: './src/theme.css' in docsmith(). Keep body text at 4.5:1 contrast on
its surface and --primary at 3:1 on --background.
To hand the theme to a person to look at and adjust, give them a theme link.
The format is stable: https://docsmith.geodask.com/themes#theme= followed by
base64url of raw deflate of this JSON.
Token names have no leading --. light and dark each hold a whole mode, and
a token either leaves out is generated from the rest. An optional inputs object only sets the builder’s guided controls, and is inferred when missing.
This script builds the link from a theme file:
npx svelte-docsmith theme --link '<link>' writes a link’s theme into a
project, so an agent and a person can pass one theme back and forth.
Code colours
Code blocks read the --code-* tokens, so they follow the theme in light and
dark with no setting. Each preset sets its own syntax colours, chosen from its
palette and readable on its background. A theme without them gets colours mixed
from its primary and chart colours.
To use an exact Shiki theme instead, name a pair:
codeTheme takes any Shiki theme names and
ignores the --code-* tokens.
Dark mode
Dark mode is class-based: a theme’s .dark block applies when the dark class
is on <html>. DocsShell mounts ModeProvider, which sets that class,
follows the reader’s system preference and remembers their choice, and the
header’s ModeToggle switches it. You install and wire nothing.
For a page you build outside DocsShell, wrap it in ModeProvider:
Fonts
Three families are tokens: --font-sans, --font-serif and --font-mono. theme.css loads Inter, Source Serif 4 and JetBrains Mono for the defaults. To
use your own, load the faces however you normally would (a <link> in app.html, @fontsource, or your host) and set the families in your theme or app.css: