|
Download react-use/docs/useCss.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useCss.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useCss.md
-
curl -L -o useCss.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useCss.md
1.03 kB
useCss
React UI hook that changes CSS dynamically. Works like "virtual CSS" — it re-renders only CSS rules that change. It is different from inline styles, because you can use media queries and pseudo selectors.
Usage
import {useCss} from 'react-use';
const Demo = () => {
const className = useCss({
color: 'red',
border: '1px solid red',
'&:hover': {
color: 'blue',
},
});
return (
<div className={className}>
Hover me!
</div>
);
};
Examples
const className = useCss({
color: 'tomato',
'&:hover': {
color: 'orange',
},
});
const className = useCss({
svg: {
fill: 'tomato',
},
'.global_class &:hover svg': {
fill: 'orange',
},
});
const className = useCss({
color: 'tomato',
'@media only screen and (max-width: 600px)': {
color: 'orange',
'&:hover': {
color: 'red',
}
},
});