Last active
December 25, 2025 05:36
-
-
Save mebiusbox/1d0841d1824e8d85752bd2dd8f867f21 to your computer and use it in GitHub Desktop.
vite_js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect, useState } from "react"; | |
| const useDarkMode = () => { | |
| // const [enabled, setEnabled] = useLocalStorage('dark-theme'); | |
| const [enabled, setEnabled] = useState(false); | |
| const isEnabled = typeof enabledState === 'undefined' && enabled; | |
| useEffect(() => { | |
| const className = 'dark'; | |
| const bodyClass = window.document.body.classList; | |
| isEnabled ? bodyClass.add(className) : bodyClass.remove(className); | |
| }, [enabled, isEnabled]); | |
| return [enabled, setEnabled]; | |
| }; | |
| export default useDarkMode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { clsx } from "clsx"; | |
| import { twMerge } from "tailwind-merge"; | |
| export function cn(...inputs) { | |
| return twMerge(clsx(inputs)); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment