@37nerds/use-theme-toggle
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

use-theme-toggle

Simple react hook for handling theme toggle logic

Install

npm install @37nerds/use-theme-toggle # or
yarn add @37nerds/use-theme-toggle # or
pnpm install @37nerds/use-theme-toggle

Usage

import useThemeToggle from "@37nerds/use-theme-toggle";

const ThemeToggle = () => {
    const {theme, setTheme } = useThemeToggle({
        onLight: () => {
            document.documentElement?.classList.remove("dark");
        },
        onDark: () => {
            document.documentElement?.classList.add("dark");
        },
    });

    return (
        ...
    );
};

Readme

Keywords

Package Sidebar

Install

npm i @37nerds/use-theme-toggle

Weekly Downloads

6

Version

0.1.2

License

MIT

Unpacked Size

11.9 kB

Total Files

9

Last publish

Collaborators

  • p-nerd