Themes

Color, type and spacing tokens, status, priority and choice colors, and light, dark and app themes you can nest.

Preview

Surfaces

app
panel
raised
selected

Text and accent

fg
muted
accent

Roles

info
success
warning
danger
agent

Type

AaHeadingTitleBody textCaption

Status

triagebacklogtodoprogressreviewblockeddonecanceled

Priority

urgenthighmediumlownone

Choice

grayredorangeyellowgreenblueindigopurple

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/themes

Usage

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

AppTheme options
NameTypeDescription
accentrequiredColorValueButtons, links, selection and the focus ring
accentFgColorValueText on the accent; picked for contrast when left out
focusRingColorValueThe 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)
colorPartial<Record<Exclude<ColorToken, "accent" | "accentFg" | "focusRing">, ColorValue>>Any other color token: surfaces, text, lines, tones
statusPartial<Record<StatusToken, ColorValue>>—
priorityPartial<Record<PriorityToken, ColorValue>>—
choicePartial<Record<ChoiceToken, ColorValue>>—
fontPartial<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 move drop to zero.

Source