Themes and icons
The live theme, design tokens, shipped palettes, accessible contrast, custom themes and icons.
There is one live *theme.Theme (theme.Current()). theme.Use("yoga-light") overwrites it in place, so the next paint picks up the new palette with no rebuild.
Prefer tokens (ui.TokenSurface, ui.TokenChrome, ui.TokenForeground, ui.TokenAccent, ui.TokenBorder, ui.TokenError, …) over literal colors so chrome follows the theme.
ui.Column(...).Background(ui.TokenChrome)
ui.Text("status").Style(ui.Spec{}.TextColor(ui.TokenForegroundMuted))Default theme is yoga-dark. If you switch before opening the window, call theme.Use before yoga.Run.
Shipped names: yoga-dark, yoga-light, system, yoga-high-contrast, yoga-high-contrast-light, yoga-colorblind-dark, yoga-colorblind-light, yoga-midnight, github-dark, github-light, catppuccin, catppuccin-latte, dracula, nord, solarized-dark, solarized-light, gruvbox-dark, gruvbox-light, monokai, tokyo-night, tokyo-night-day, one-dark, one-light, everforest-dark, everforest-light (theme.Names()).
Use theme.Use("system") to follow the platform dark/light setting; the runtime re-syncs each frame. theme.Selected() returns "system" while that mode is active; theme.Current() holds the resolved palette.
theme.UseSystem(name) follows the OS appearance within a theme family, so a reader on catppuccin gets catppuccin-latte in daylight instead of being moved to the yoga palette. Each theme names its counterpart through LightSibling / DarkSibling; themes with no counterpart stay put.
Two themes exist for accessibility rather than taste: yoga-high-contrast-light for readers who need maximum contrast on a light workspace, and the yoga-colorblind-* pair, whose status colors come from the Okabe-Ito palette so Error, Warning and Success stay separable without color vision.
Every shipped palette is checked against WCAG 2.1 AA by theme's contrast tests: 4.5:1 for text on every surface it can land on, 3:1 for control outlines and focus rings. Tokens that are defined by a contrast relationship rather than by taste — BorderControl, FocusRing, the *Foreground / *Surface status pairs, and the editor washes — are derived from the palette in normalize, so a custom theme only sets its brand colors and still passes. Use theme.ContrastRatio to check your own.
To write a theme, pick a 12-step neutral ramp, an accent and three status colors, and let theme.FromPalette derive the rest — the result meets the same contrast targets as the shipped themes:
t := theme.FromPalette(theme.Palette{
Name: "acme-dark", Dark: true,
// sunken, surface, chrome, chrome-muted, overlay, border,
// hover, pressed, subtle, muted, disabled, text
Neutral: theme.Ramp{ /* 12 colors, darkest to lightest */ },
Accent: render.RGBA8(53, 103, 214, 255),
Error: render.RGBA8(229, 72, 77, 255),
Warning: render.RGBA8(245, 185, 74, 255),
Success: render.RGBA8(70, 184, 100, 255),
})
theme.Register(t)
theme.Use("acme-dark")For text, always use the *Foreground status tokens (th.ErrorForeground), never the raw th.Error hue: an amber Warning cannot reach 4.5:1 on a light surface. Draw focus rings through th.FocusRingOn(fill) rather than reading th.FocusRing, so the ring stays visible on accent-filled controls.
Spacing, radius, stroke, and type ramps live on c.Theme() (th.Spacing.M, th.Radius.Medium, th.Stroke.Thin, th.Typography.Body).
Icons are pre-rasterized Lucide symbols from github.com/yogaui/yoga/icons (e.g. icons.Search, icons.Plus, icons.ChevronDown). Unused icons are dropped by the Go linker. The full catalog lives in icons/catalog for the component gallery. Regenerate with go run ./cmd/generate-lucide. Custom SVGs: render.RegisterIcon(name, svg) before first draw.
Lucide is licensed under the ISC License.
Edit this page on GitHub