usePreferredDark
React Hook that tracks dark theme preference
Usage
Live Editor
function Demo() { const isDark = usePreferredDark(false); return <div>PreferredDark: {JSON.stringify(isDark)}</div>; };
Result
Loading...
API
usePreferredDark
Returns
boolean
: whether prefer dark
Arguments
Argument | Description | Type | DefaultValue |
---|---|---|---|
defaultState | defaule value | boolean | undefined | - |