Skip to main content

1. Import the barrel file

Everything — tokens, theme, components, context extensions — is exported from one file:

2. Read tokens from context

Inside any build method, grab the current theme’s tokens via the two BuildContext extensions:
These resolve against the ambient Theme, so the same code renders correctly in light mode, dark mode, and under any persona accent palette.

3. Reach for existing components first

Before building a custom widget, check what already exists:
Variants use named constructors, not parameters: StyledCard.outlined(), StyledCard.filled(), StyledTextField.underline(). See the Components section for every widget.

4. Accent-colored (persona) UI

Persona-branded elements use the accent tokens nested in the color theme:
(In practice, a plain ElevatedButton already gets these colors from the app theme — see Material bridge.)

The golden rules

1

Never hardcode colors or text styles

Every color comes from context.colorTheme, every text style from context.textTheme. No Color(0xFF…), no TextStyle(fontSize: …) in feature code.
2

Semantic over primitive

Use colors.surfaceBg, not SundialRef.sandLight[1]. Semantic tokens adapt to light/dark automatically; primitives don’t.
3

Use accent tokens for persona branding

Anything that should follow the user’s persona uses colors.accent.* — never a specific palette’s colors.
4

Test both brightness modes

Every screen must hold up in light and dark. If you need to force a subtree, use ThemeOverride.