Core
Explore core utilities of dynawind.
Utility functions for applying and generating scoped CSS variables for theming.
generateSemanticColorCSSVariables
Generates scoped CSS variable declarations for a color theme.
Parameters
theme:Theme— An object mapping semantic color keys to CSS values.
Returns
A string of CSS custom properties in the format --color-<key>: <value>;.
Example
applySemanticColorThemeToRoot
Applies a color theme directly to the <html> element using CSS custom properties.
Parameters
theme:Theme— Color theme variables.
Example
applyThemeToRoot
Applies a scoped or unscoped theme to the root of the document.
Parameters
scope:string | null | undefined— Optional prefix used for the CSS variables (e.g.,color,typography). Ifnullorundefined, variables are unscoped.theme:Theme— Key-value pairs of CSS variables.
Example
generateCSSVariables
Converts a theme object into scoped or unscoped CSS variable declarations.
Parameters
scope:string | null | undefined— Optional namespace for the variables. Ifnullorundefined, variables are generated without a scope.theme:Theme— CSS variable mappings.
Returns
A string of scoped or unscoped CSS variables.
Example
wrapInRoot
Wraps multiple CSS variables in a :root block.
Parameters
cssVars:string[]— An array of CSS variable declarations.
Returns
A single CSS string wrapped in :root.