useCssVar ​
utilities
test coverage
Last changed: 24 days ago
Hook that returns the value of a css variable
typescript
import { useCssVar } from '@siberiacancode/reactuse';
Usage ​
typescript
const { ref, value, set } = useCssVar('--color', 'red');
// or
const { value, set } = useCssVar(ref, '--color', 'red');
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
key | string | - | The CSS variable key |
initialValue | string | - | The initial value of the CSS variable |
Parameters
Name | Type | Default | Note |
---|---|---|---|
target | HookTarget | - | The target element |
key | string | - | The CSS variable key |
initialValue | string | - | The initial value of the CSS variable |