Appearance Menu
Navigation · AppearanceMenu
The look menu at the end of the top bar: theme (auto, light, dark), brand colour, density (auto, roomy, compact), motion (normal, lively, off), glass surfaces and, with both kits, the kit. Behind a sun or a moon, as in the standard app frame. On phones it opens as a bottom sheet.
- Put
AppearanceProvideraround the app instead ofUIProvider: it applies the choice and keeps it in this browser (storageKey, default"tf-appearance"). It takes everyUIProviderprop (locale,messages,floating…) andkits={["halo", "pro"]}when both kits are loaded (themes.css); then the menu shows the style row. appearanceScript(storageKey)in<head>puts the stored look on<html>before the first paint, so a reload does not flash.- Per account instead of per browser:
initial(the stored value),onChange(next, patch)(save it),storageKey={false}, andhint="Saved for your account"on the menu. - Brand colour: the kit's own primary ("Default"), the six
THEME_PRESETS(blue, violet, emerald, orange, rose, teal) or a custom colour from the colour picker, which goes throughbrandTheme. The value (brand: a preset key or a hex colour) is part of the stored look and ofappearanceScript, so the colour is there before the first paint too. - Hovering a choice previews it before it is picked (
onPreview(patch),nullwhen the pointer leaves); inside anAppearanceProviderthe app shows the preview without storing it. - With glass on,
AppearanceProviderpaints anAmbientbehind the app so the glass has something to show;ambient={{ colors: [...] }}orambient={{ src: "/backdrop.jpg" }}sets your own,ambient={false}leaves the background to you. rowspicks the rows ("kit","theme","brand","density","motion","surface"); leave out"brand"for an app with a fixed brand colour.valueandonChangework without a provider (controlled: store the choice per user on your server).useAppearance()gives the state for your own menu.sheet={false}keeps the popover on phones. InAppShell,appearance(orappearance={{ hint: "Saved for your account" }}) puts the menu at the end of the top bar.- Kit and theme changes cross-fade where the browser supports view transitions and motion is on.
tsx
// app/layout.tsx
<head>
<script dangerouslySetInnerHTML={{ __html: appearanceScript() }} />
</head>
<body>
<AppearanceProvider kits={["halo", "pro"]} floating="solid">{children}</AppearanceProvider>
</body>
// in the AppShell
<AppShell navigation="sidebar" topbar appearance … />
Props
AppearanceMenu
| Prop | Type | Notes |
|---|---|---|
value? | Appearance | The current look; without it the menu reads and writes the nearest `AppearanceProvider`. |
onChange? | (patch: Partial<Appearance>) => void | |
kits? | Kit[] | Kits to choose from; with two or more the menu shows the Style row. |
rows? | AppearanceRow[] | The rows to show (default: style when there are kits, theme, colour, density, motion and glass). Leave `"brand"` out for an app with a fixed brand colour. |
onPreview? | (patch: Partial<Appearance> | null) => void | While the reader hovers a choice (or drags the custom colour), before it is picked; `null` when the pointer leaves. Without it the menu previews through the nearest `AppearanceProvider`. |
sheet? | boolean | On phones the menu opens as a bottom sheet (default true). |
hint? | ReactNode | Under the title, e.g. "Saved for your account" (default "Saved on this device"). |
align? | "start" | "end" | Which edge of the trigger the menu lines up with (default `end`, for the top bar's end). |
side? | "top" | "bottom" | Opens below the trigger (default) or above it. |
open? | boolean | Controls whether the menu is open (e.g. to show it open in a tour). |
onOpenChange? | (open: boolean) => void | |
className? | string | Extra class on the root element. |
style? | CSSProperties | Inline style on the root element. |