Loading...
Loading...
> Light/Dark color themes + Terminal/Modern visual styles.
Dual theme system: Color themes (light/dark) and Visual themes (Terminal/Modern). Persistent localStorage, no theme flash, and Tailwind v4 native.
Compact dropdowns for navbar
1import { ThemeDropdown } from "@/components/theme/theme-dropdown";2import { VisualThemeDropdown } from "@/components/theme/visual-theme-dropdown";34export function MyNavbar() {5 return (6 <nav>7 <ThemeDropdown /> {/* Light/Dark color switcher */}8 <VisualThemeDropdown /> {/* Terminal/Modern visual switcher */}9 </nav>10 );11}
Dual theme system via data attributes
1<!-- Color theme via data-theme (light/dark) -->2<html data-theme="light" data-visual-mode="terminal">3 <!-- data-theme="light" sets colors (light or dark) -->4 <!-- data-visual-mode="terminal" sets visual style -->5</html>67<!-- Themes auto-loaded before React hydration (no flash) -->8<script>9 const theme = localStorage.getItem('theme') || 'light';10 const visualMode = localStorage.getItem('fabrk-theme-visual-mode') || 'terminal';11 document.documentElement.setAttribute('data-theme', theme);12 document.documentElement.setAttribute('data-visual-mode', visualMode);13</script>
Each theme defines CSS variables in globals.css
1/* Light theme (default colors) */2[data-theme="light"] {3 --background: 99% 0 0; /* Off-white */4 --foreground: 0% 0 0; /* Pure black */5 --primary: 0% 0 0; /* Black */6 --accent: 55% 0.21 250; /* Vercel blue */7 /* ...more variables */8}910/* Dark theme */11[data-theme="dark"] {12 --background: 0% 0 0; /* Pure black */13 --foreground: 100% 0 0; /* Pure white */14 --primary: 100% 0 0; /* White */15 --accent: 55% 0.21 250; /* Vercel blue */16 /* ...more variables */17}1819/* Terminal visual style (sharp edges, monospace) */20[data-visual-mode="terminal"] * {21 border-radius: 0 !important;22}2324/* Modern visual style (rounded, sans-serif) */25[data-visual-mode="modern"] * {26 border-radius: 0.5rem !important;27}
Always use semantic color classes
1// ✅ GOOD - Theme-aware colors2<button className="bg-primary text-primary-foreground">3 Matches active theme (light or dark)4</button>56<div className="border-primary ring-primary">7 Adapts automatically when user switches themes8</div>910// ❌ BAD - Hardcoded colors (breaks theming)11<button className="bg-[hardcoded] text-[hardcoded]">12 Always same color, ignores theme selection13</button>
Modify light/dark themes in globals.css
1/* Customize existing themes in globals.css */2[data-theme="light"] {3 --background: 99% 0 0;4 --foreground: 0% 0 0;5 --primary: 0% 0 0;6 --accent: 55% 0.21 250; /* Vercel blue - customize to your brand */7 /* ...modify other variables */8}910[data-theme="dark"] {11 --background: 0% 0 0;12 --foreground: 100% 0 0;13 --primary: 100% 0 0;14 --accent: 65% 0.21 250; /* Brighter for dark mode */15 /* ...modify other variables */16}