useDarkMode
Custom hook that returns the current state of the dark mode.
Installation
npx sse-hooks add use-dark-mode
yarn dlx sse-hooks add use-dark-mode
pnpm dlx sse-hooks add use-dark-mode
deno run -A npm:sse-hooks add use-dark-mode
bunx sse-hooks add use-dark-mode
Usage
example.ts
import { useDarkMode } from "./{hooks file}";
const { isDarkMode, toggle, enable, disable, set } = useDarkMode({
defaultValue: true,
});
API
Parameters
| Prop | Default | Type |
|---|---|---|
options |
|
The initial value of the dark mode, default
|
Returns
| Return Value | Default | Type |
|---|---|---|
disable | - |
Function to disable the dark mode. |
enable | - |
Function to enable the dark mode. |
isDarkMode | - |
The current state of the dark mode. |
set | - |
Function to set a specific value to the dark mode. |
toggle | - |
Function to toggle the dark mode. |
Types Aliases
No specific type aliases defined for this component.