theme

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package theme is the canonical home for the framework's visual design system.

The theme provides curated tokens — colors, spacing, radii, fonts — that every framework/ui component references via CSS custom properties. To re-skin an app, pass overrides to Default; every component re-resolves to the new values without code changes. Default includes a complete adaptive dark palette, so ThemeToggle and the synchronous OS-preference bootstrap are safe without extra host setup.

Tokens are single-tier semantic: names carry meaning ("primary", "danger", "surface-soft") rather than raw values ("indigo-500"). If you need a deeper layering, build it on top — but most apps don't.

The output is a style.Theme (from core-ui/style), so this package composes cleanly with the existing stylesheet builder and any host that already consumes core-ui themes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default(overrides ...Overrides) style.Theme

Default returns the canonical adaptive framework theme, including complete light and dark semantic palettes.

Pass an Overrides value to swap individual tokens. Overrides are applied on top of the typed style.DefaultTheme(); unset fields keep their defaults.

Example — swap primary from indigo to teal in both palettes:

t := theme.Default(theme.Overrides{
	Primary: "#0F766E",
	DarkColors: map[string]string{"primary": "#5EEAD4"},
})

Every component referencing --color-primary updates without any code change.

Types

type Overrides

type Overrides struct {
	// Color tokens (CSS hex values).
	Background, Surface, SurfaceSoft string
	Border, BorderStrong             string
	Text, TextMuted, TextSubtle      string
	Primary, PrimaryFg               string
	Accent                           string
	Success, Warning, Danger, Info   string

	// Code-display surface tokens (ui.CodeBlock + demo source panels).
	// Intentionally a separate pair so dark mode reskins code blocks
	// independently of the page Text/Background pair.
	CodeSurface, CodeText, CodeBorder string

	// DarkColors explicitly overrides semantic dark-palette tokens by their
	// CSS name (for example "primary" or "surface-soft"). Light color fields
	// are not copied into dark mode because a contrast-safe dark value is
	// usually different.
	DarkColors map[string]string

	// Font families.
	FontBody, FontHeading, FontMono string

	// Reskin extras — only apply if you really need them.
	RadiusSm, RadiusMd, RadiusLg int // px
}

Overrides is the set of tokens a host can swap to re-skin the framework theme. All fields are optional. Empty strings are ignored — zero-value RadiusXX ints likewise.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL