@modular/sdk/theme
14 exports in 3 groups.
Interfaces1
Types3
- ModularThemeDefinitiontype{ readonly [Category in keyof ModularThemeTokens]?: { readonly [Token in keyof ModularThemeTokens[Category]]?: ModularThemeTokens[Category][Token] } }
- ModularThemeTokenstypeOmit<SemanticTokenContract, 'surface'> & { color: { readonly [Token in PaletteTokenName]: string }; surface: Omit<SemanticTokenContract['surface'], 'material'> & { material: SurfaceMaterial } }
- ResolvedTokenstypeRepresents a fully resolved token structure where all categories and tokens are readonly. This is the shape of tokens after all references and computed functions have been resolved.
Functions10
- defineModularThemefunction(definition: ModularThemeDefinition) => ModularTheme
- adjustHuefunctionAdjust the hue of a color. Rotates the hue on the color wheel.
- alphafunctionSet the alpha/opacity of a color.
- contrastfunctionGet a contrasting color (black or white) for text readability. Uses WCAG relative luminance calculation to determine the best contrast.
- darkenfunctionDarken a color by a percentage. Works in HSL space for perceptually uniform results.
- defineThemefunctionDefine a theme with full type safety. Creates a theme from a definition where tokens can be: - Literal values (`'#007bff'`, `16`) - References to other tokens (`'$color.brand'`) - Computed functions (`(t) => t.spacing.base * 4`) The returned Theme object provides: - `tokens`: Fully resolved token values with autocomplete - `css`: Generated CSS custom properties string - `extend()`: Method to create derived themes with overrides
- lightenfunctionLighten a color by a percentage. Works in HSL space for perceptually uniform results.
- mixfunctionMix two colors together. Uses linear interpolation in RGB space.
- saturatefunctionAdjust the saturation of a color. Works in HSL space.
- tokenAccessorfunctionCreate a typed token accessor helper for computed functions. This enables autocomplete on the `t` parameter in callbacks. The accessor returns an identity function that preserves the callback type while providing full type inference for the tokens parameter.