---
title: "Appearance"
description: "Configure themes, light and dark modes, typography, and optional appearance controls with Unirepo."
status: published
publishedAt: "2026-11-17T00:34:10Z"
updatedAt: "2026-11-17T00:34:10Z"
tags: [docs]
---
## One configuration, your controls
Unirepo provides a headless appearance provider. Your app chooses the controls,
translations, layout, and supported features. The website uses this same API:
**Aa · Unirepo Default** is its first built-in theme.
~~~tsx
import { appearanceConfig, unirepoDefaultTheme } from 'unirepo/appearance';
export const config = {
...appearanceConfig,
storageKey: 'my-app-appearance-v1',
legacyStorage: undefined,
defaultTheme: 'my-default',
themes: [{ ...unirepoDefaultTheme, id: 'my-default', name: 'My Default' }],
features: ['mode', 'themes', 'accent', 'font', 'heading', 'reading'],
} satisfies typeof appearanceConfig;
~~~
Keep configuration outside the component. Presets are immutable templates;
customizing one creates a saved copy. Add presets to the themes array.
## Provider and startup
~~~tsx
'use client';
import type { ReactNode } from 'react';
import { AppearanceProvider } from 'unirepo/appearance';
import { config } from './appearance-config';
export function Providers({ children }: { children: ReactNode }) {
return {children};
}
~~~
Use createAppearanceScript(config) from unirepo/appearance before the
page paints, with the same configuration. Serve it as an external script if your
content security policy requires that. The site uses /appearance.js.
The initial React render stays deterministic; disable controls until ready.
The provider sets data-theme, data-color, data-ui-*, reading variables, and
data-page-width on the document. Your stylesheet supplies their appearance.
The site uses its shared UI theme stylesheet, plus:
~~~css
@import "unirepo/appearance/surface.css";
@import "unirepo/appearance/typeset.css";
@import "unirepo/appearance/preferences.css";
~~~
Use your own shadcn Typeset stylesheet instead of the bundled copy if preferred.
Do not mount ReadingProvider, SurfaceProvider, or another theme provider
alongside this provider: they would write competing document preferences.
## Optional features
Feature
Control
mode
Light, Dark, System
themes
Presets; create, edit, duplicate, save, and delete custom themes
separateModes
Independent light and dark variants
accent, base, chart
Semantic color choices
font, heading
Interface body and heading fonts
radius, menu, menuColor, menuAccent
Shape and menu treatment
reading
Typeset preset, fonts, size, leading, spacing, and measure
layout
Comfortable or full page width
Use enabled(feature) when rendering controls. Features enable editing;
presets still establish the app’s design. Layout is a separate user
preference, not part of a saved theme. Layouts must respond to data-page-width.
## Editing a theme
Import useAppearance from unirepo/appearance.
~~~tsx
const appearance = useAppearance();
// Open a draft from a user action.
// Once a draft is open:
~~~
Give the draft a name with renameDraft(name) before saving. Drafts preview live;
cancel() restores the saved theme. Reloading discards unsaved drafts.
editTheme(true) duplicates the selection. selectTheme(id) switches themes.
deleteTheme() removes the selected custom theme and returns to the default;
built-in presets cannot be deleted. setMode() changes mode independently.
With separate modes off, both modes share choices while CSS adapts the palette.
With it on, edit light and dark independently. Preview follows the display mode.
## Fonts and reading
Apps load their fonts. Interface choices currently use installed sans,
serif, and mono stacks. Reading typography accepts a font-ID-to-CSS-stack map
in config.reading.fonts and matching reading presets. Builder links do not
automatically download fonts.
Use className="typeset reading" for editorial content. Keep UI outside that wrapper.
Apply the reading-measure variable only to reading columns, not the whole page.
## Persistence
Themes use versioned browser local storage, not an account. Saved changes
synchronize between tabs. Storage failure keeps changes usable for the visit and
exposes storageError so the UI can explain they were not persisted.
Invalid values fall back safely.
The site imports previous preferences without deleting the original keys.
For a new app, omit legacyStorage. Mode follows system changes automatically.
Provide labels, keyboard access, RTL support, and sufficient contrast.
A future CLI can generate this configuration; its init wizard is not implemented.
## Visual presets
The website registers **Unirepo Default** and **OpenCode**. A visual preset defines
component recipes, navigation treatment, icon assets and motion; a theme references
that preset and supplies its light/dark colors and typography. Custom copies retain
their preset so changing a color does not discard the design.
~~~ts
import { defineAppearancePreset } from 'unirepo/appearance';
export const preset = defineAppearancePreset({
id: 'my-app',
tokens: { '--appearance-button-tracking': 'normal' },
components: { button: 'soft' },
layout: { navigation: 'surface' },
motion: { duration: 150 },
});
~~~
Register it in `defineAppearanceConfig({ ...config, presets: [preset] })` and set
`preset: 'my-app'` on the theme. Your app implements the recipes and registers its
icon assets; this definition alone does not generate CSS or components.
Each site preset has `index.ts`, `tokens.css`, `typography.ts`, `icons.ts`,
`components.ts`, `layouts.ts`, and `motion.ts`. The site implementation is in
`apps/site/src/appearance`. Shared layout rules remain outside individual presets.
The pre-paint script restores the selected preset before hydration. Semantic
Tailwind classes follow its variables, without remounting the article. The proof
currently covers Button, navigation, menu/language icons, colors and typography.
Automatic shadcn imports and CLI generation are planned, not implemented.