mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-20 13:48:16 +02:00
Add files via upload
This commit is contained in:
72 files changed
+12339
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
export function useTheme() {
|
||||
const [theme, setTheme] = useState(localStorage.getItem('theme') || 'dark');
|
||||
|
||||
useEffect(() => {
|
||||
const root = window.document.documentElement;
|
||||
root.classList.remove('light', 'dark');
|
||||
root.classList.add(theme);
|
||||
localStorage.setItem('theme', theme);
|
||||
}, [theme]);
|
||||
|
||||
const toggleTheme = () => setTheme(prev => prev === 'dark' ? 'light' : 'dark');
|
||||
|
||||
return { theme, toggleTheme };
|
||||
}
|
||||
Reference in new issue
Block a user