Theming
/ API ReferenceTheming
/ API ReferencecreateVariable
A small utility function that creates a CSS variable and its reference.
Primarily useful when creating lower-level abstractions like createTheme or createThemes.
The Gist
import { createVariable } from '@weser/theming'
const [reference, declaration] = createVariable('brand-color', 'red')
// => 'var(--brand-color)'
console.log(reference)
// => '--brand-color:red'
console.log(declaration)
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The CSS variable name |
value | string | The value assigned to the variable |
Returns
([string, string]
) A tuple where the first element is a string referencing the CSS variable and the second element is a string referencing the variable declaration to be inlined somewhere in your application.
© 2024-present Robin Weser. All Rights Reserved.