Customization
Dark Mode
Switch between light and dark themes to optimize viewing experience.
Preview
Settings
Current Mode: DARK
Click the toggle to preview theme transition.
Implementation
Use CSS variables to easily handle color switching.
/* globals.css */:root {--bg-primary: #ffffff;--text-primary: #111111;}[data-theme='dark'] {--bg-primary: #0a0a0a;--text-primary: #ffffff;}body {background-color: var(--bg-primary);color: var(--text-primary);transition: background-color 0.3s ease;}
React Hook
import { useEffect, useState } from 'react';export function useTheme() {const [theme, setTheme] = useState('dark');useEffect(() => {document.documentElement.setAttribute('data-theme', theme);}, [theme]);const toggleTheme = () => {setTheme(prev => prev === 'dark' ? 'light' : 'dark');};return { theme, toggleTheme };}