0.1.2 • Published 11 months ago

@37nerds/use-theme-toggle v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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 (
        ...
    );
};
0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago