Spaces:
Paused
Paused
Download apps/web/src/lib/use-theme.ts from mohammed978/teteffd: direct link, hf CLI and curl.
- Browser
- Download file 460 Bytes
-
https://huggingface.co/spaces/mohammed978/teteffd/resolve/main/apps/web/src/lib/use-theme.ts
- Command line
-
hf download hf://spaces/mohammed978/teteffd/apps/web/src/lib/use-theme.ts
-
curl -L -o use-theme.ts https://huggingface.co/spaces/mohammed978/teteffd/resolve/main/apps/web/src/lib/use-theme.ts
460 Bytes
| 'use client' | |
| import * as React from 'react' | |
| export function useTheme(): boolean { | |
| const [dark, setDark] = React.useState(false) | |
| React.useEffect(() => { | |
| const root = document.documentElement | |
| setDark(root.classList.contains('dark')) | |
| const obs = new MutationObserver(() => setDark(root.classList.contains('dark'))) | |
| obs.observe(root, { attributes: true, attributeFilter: ['class'] }) | |
| return () => obs.disconnect() | |
| }, []) | |
| return dark | |
| } | |