Theming & Dark Mode
Token model
The native bloodline's token source of truth lives in lh-ui-core/tokens/*.json; codegen produces the iOS artifacts:
| Artifact | Contents | Dark form |
|---|---|---|
LhTokens | Full light set: Button sizes, Color palette, Motion, Radius, Shadow, Spacing, Typography, ZIndex | — |
LhDarkTokens | Only the Color sub-object (side-by-side object model) | Dark overrides colors only; sizes / motion / radius are unchanged in dark |
LhShadow | SwiftUI shadow carrier struct (color/opacity/radius/x/y) | — |
This matches android / harmony / windows (side-by-side objects) and differs from the docs end (shallow JSON merge). The theme layer is designed accordingly:
LhColorscarries colors only, while sizes are read straight fromLhTokensby components.
LhColors
LightLhColors / DarkLhColors flatten the two generated enums into a single Equatable value type:
public struct LhColors: Equatable {
public let primary: Color
public let onPrimary: Color
// ... all semantic colors
}
public let LightLhColors = LhColors(primary: LhTokens.Color.Primary.`default`, /* ... */)
public let DarkLhColors = LhColors(primary: LhDarkTokens.Color.Primary.`default`, /* ... */)The initializer is public: unit tests can construct a palette directly to assert against it; application code should consume it through LhTheme.
LhTheme
LhTheme(isDark: true) {
// Environment(\.lhColors) injects DarkLhColors; components inside consume it automatically
}Without an LhTheme wrapper, the Environment key's defaultValue falls back to LightLhColors (the default is the light palette).
Dark pre-computation (important)
The web bloodline evaluates dark colors dynamically with CSS color-mix(); native has no CSS cascade, so core pre-computes the dark expressions into literals (e.g. rgba(61,100,158,0.25), #B1C1D8). The consequence (master plan R-n6):
When you change the preset primary color, the pre-computed dark values do not follow automatically. You must recompute them by hand and update
lh-ui-core/tokens/color-dark.json, and refresh the Design Language Baseline accordingly.
iOS-specific conventions
- Durations are in seconds:
LhTokens.Motion.Duration.base = 0.300(android/harmony use milliseconds, and so does C), consumed directly by the SwiftUI animation APIs with no conversion. - Color representation: the generated artifacts use normalized RGB (
SwiftUI.Color(red:green:blue:)+.opacity()), not hex strings. - Corner radius:
Radius.circleis a 0.5 fraction; the end converts it withmin(width, height) / 2— it cannot be used as a pt value. - Shadow: SwiftUI has no spread parameter, so the generated
LhShadowignores spread and notes it in a comment. - Fonts:
Typography.fontFamilyis a font-stack string; the end picks the first available family. The Chinese-style serif is the default character.
Token quick reference
The full token table (light / dark / notes) is in the core repo at dist/docs/tokens.md (generated by pnpm codegen). For component-level token mappings, see the Button token reference.

