useTernaryDarkMode
Custom hook that manages ternary (system, dark, light) dark mode with local storage support.
Installation
npx sse-tool add use-ternary-dark-mode
npm install sse-hooks
Usage
import { useTernaryDarkMode } from "./{hooks file}";
const {
isDarkMode,
ternaryDarkMode,
setTernaryDarkMode,
toggleTernaryDarkMode,
} = useTernaryDarkMode({ defaultValue: "dark" });
// Access and use the dark mode state and provided helper functions.
import { useTernaryDarkMode } from "sse-hooks";
const {
isDarkMode,
ternaryDarkMode,
setTernaryDarkMode,
toggleTernaryDarkMode,
} = useTernaryDarkMode({ defaultValue: "dark" });
// Access and use the dark mode state and provided helper functions.
API
Parameters
| Name | Type | Description |
|---|---|---|
| options | TernaryDarkModeOptions | Options or the local storage key for the hook. |
Return Value
Returns TernaryDarkModeReturn.
An object containing the dark mode state and helper functions.