Color, type and spacing tokens, status, priority and choice colors, and light, dark and app themes you can nest.
Surfaces
apppanelraisedselectedText and accent
fgmutedaccentRoles
infosuccesswarningdangeragentType
AaHeadingTitleBody textCaption
Status
triagebacklogtodoprogressreviewblockeddonecanceled
Priority
urgenthighmediumlownone
Choice
grayredorangeyellowgreenblueindigopurple
Installation
pnpm dlx shadcn@latest add checkfu/uicontext/themesUsage
import { ChangeScheme, createAppTheme, SchemeChoice } from "./ui/uicontext/components/AppTheme.ts"import { SegmentedControl } from "./ui/uicontext/components/SegmentedControl.ts"import { choice, priority, status } from "./ui/uicontext/components/tokens.stylex.ts"export const theme = createAppTheme({ accent: { light: "#0b6bcb", dark: "#5aa9ff" } })export const contrastIssues = theme.issues // [] when the accent passes WCAG AA// Status, priority and choice colors read at 4.5:1 on every surface.export const styles = stylex.create({ done: { color: status.done }, urgent: { color: priority.urgent }, pill: { backgroundColor: `color-mix(in srgb, ${choice.green} 14%, transparent)`, color: choice.green },})// Light, dark or the device's: index.html's head runs `schemeScript` before anything paints, so a// reload shows the saved pick at once; `ChangeScheme` switches and saves it.const Message = UiSchema.TaggedEnum({ PickedScheme: { scheme: SchemeChoice } })// in update: PickedScheme: ($, { scheme }) => $.evolve({ scheme }).run(changeScheme(scheme))export const changeScheme = (scheme: SchemeChoice) => ChangeScheme.make({ scheme }).pipe(Command.asNoop)export const AppearancePicker = (h: Html.H<typeof Message.Type>, scheme: SchemeChoice) => SegmentedControl(h, { label: "Appearance", value: scheme, options: [ { value: "light", label: "Light" }, { value: "dark", label: "Dark" }, { value: "system", label: "System" }, ], onPick: (value) => Message.PickedScheme({ scheme: value === "light" || value === "dark" ? value : "system" }), })API reference
Options
| Name | Type | Description |
|---|---|---|
accentrequired | ColorValue | Buttons, links, selection and the focus ring |
accentFg | ColorValue | Text on the accent; picked for contrast when left out |
focusRing | ColorValue | The focus ring; the accent when left out |
scheme | "system" | "light" | "dark" | Which of light and dark to show: "system" (default) leaves it to the page, which follows the device or the person's pick (see schemeScript and ChangeScheme) |
color | Partial<Record<Exclude<ColorToken, "accent" | "accentFg" | "focusRing">, ColorValue>> | Any other color token: surfaces, text, lines, tones |
status | Partial<Record<StatusToken, ColorValue>> | — |
priority | Partial<Record<PriorityToken, ColorValue>> | — |
choice | Partial<Record<ChoiceToken, ColorValue>> | — |
font | Partial<Record<FontToken, string>> | — |
Accessibility
- Every theme sets
color-scheme, so native controls and scrollbars match light or dark, and its focus ring color keeps 3:1 contrast against the theme's surfaces. - With reduced motion, fades keep their timing and nothing travels or grows: the motion distances and
movedrop to zero.