Skip to content

useCssVar ​

Category
Utilities

Hook that returns the value of a CSS variable

typescript
import { useCssVar } from '@siberiacancode/reactuse';

Usage ​

typescript
const { value, set } = useCssVar('color', 'red');

Demo ​

Api ​

Parameters

NameTypeDefaultNote
keystring-The CSS variable key
initialValuestring-The initial value of the CSS variable

Parameters

NameTypeDefaultNote
targetTarget-The target element
keystring-The CSS variable key
initialValuestring-The initial value of the CSS variable

Contributors ​

Source • Demo