Theming & fonts
Colours and fonts are content. Rebranding a site is editing, not refactoring.
Colours are documents
A colour theme is a Sanity document with a background, a text colour, and an optional accent. A build step reads those documents and writes a CSS variable file; components reference variable names. There are no hex codes in Vue files.
The consequence is the point: a client rebrand is content editing, not a refactor. Change the theme document, rebuild, done. Pages can carry their own theme, and individual sections can override it.
Changing the brand
Edit the colour theme in the Studio
Website → Colours. Set the background, text and accent. Optionally setdark-scheme counterparts — an empty dark slot reuses the light colour, so atheme with no dark colours looks the same in both schemes.
Regenerate the variables
Shell defineField({ name: 'heading', title: 'Heading', type: 'string', validation: (rule) => rule.required(), group: 'general', }),This runs automatically on
npm run devand as part of the build, so in practice you only run it by hand after editing colours in a running session.Set the fonts
Fonts are declared in
fonts.jsand compiled in the same way.Shell <script setup lang="ts"> import type { CustomHero, ComponentProps } from '~~/types' interface Props extends ComponentProps<CustomHero> {} const props = defineProps<Props>() </script>
Light and dark
The colour scheme is resolved at _build_ time, not render time. The generator emits every scheme-dependent value under the same variable names in each scheme's block, so switching schemes is a plain CSS cascade override, and no component needs changing.
This matters more than it sounds on a prerendered site. The server cannot know a visitor's colour scheme, so anything scheme-dependent in rendered markup — a class, an attribute, an inline style — hydrates differently than it rendered. Keeping the decision in CSS is what makes the feature safe.
Derived colours are derived at build time too: accent hover states, outline borders, elevated surfaces, gradient stops. Adding a new scheme-dependent colour means adding a variable to the generator, not a branch in a component.
| Surface | Controlled by |
|---|---|
| Site default | Site settings → theme |
| A page | The page's own colour options |
| A section | Section options → theme |
| Navigation bar | Navigation config, with a per-page override |
| Footer | Footer config, with a per-page override |
| Form inputs | Form block's input theme, defaulting to the page theme |
| Code blocks | Inherit the page theme, or use Shiki's palette |