useTernaryDarkMode
Custom hook that manages ternary (system, dark, light) dark mode with local storage support.
Installation
npx sse-hooks add use-ternary-dark-mode
yarn dlx sse-hooks add use-ternary-dark-mode
pnpm dlx sse-hooks add use-ternary-dark-mode
deno run -A npm:sse-hooks add use-ternary-dark-mode
bunx sse-hooks add use-ternary-dark-mode
Usage
example.ts
import { useTernaryDarkMode } from "./{hooks file}";
const {
isDarkMode,
ternaryDarkMode,
setTernaryDarkMode,
toggleTernaryDarkMode,
} = useTernaryDarkMode({ defaultValue: "dark" });
// Access and use the dark mode state and provided helper functions.
API
Parameters
| Prop | Default | Type |
|---|---|---|
options |
|
Options or the local storage key for the hook.
|
Returns
| Return Value | Default | Type |
|---|---|---|
isDarkMode | - |
The current state of the dark mode. |
setTernaryDarkMode | - |
A function to set the dark mode state. |
ternaryDarkMode | - |
The current state of the dark mode. |
toggleTernaryDarkMode | - |
A function to toggle the dark mode state. |
Types Aliases
No specific type aliases defined for this component.