| name | adding-themes |
| description | Adds light and dark mode theming to the SUDO codebase. Implements theme toggling using CSS custom properties and next-themes. Use when the user wants to add dark mode, light mode, theme switching, or color scheme support. |
| allowed-tools | Read, Write, Edit, Bash(npm *), Glob, Grep |
Architecture
This project uses Tailwind v4 with CSS custom properties defined in @theme inside src/app/globals.css. The current palette is dark-only (retro hacker aesthetic). The layout root is src/app/layout.tsx.
Strategy: CSS custom properties + next-themes
- Install
next-themes for theme state management
- Define two palettes via
:root (dark default) and .light class overrides in globals.css
- Wrap the app in
ThemeProvider with attribute="class"
- Add a theme toggle component
Step-by-step
1. Install next-themes
npm install next-themes
2. Update globals.css
Move color variables from @theme into :root and add .light overrides:
:root {
--color-bg: #0a0a0a;
--color-bg-dark: #050505;
--color-bg-panel: #111111;
--color-bg-card: #161616;
--color-primary: #f97316;
--color-primary-dim: #c25a0e;
--color-accent: #22c55e;
--color-accent-dim: #16803a;
--color-danger: #ef4444;
--color-danger-dim: #b91c1c;
--color-warning: #eab308;
--color-text: #e5e5e5;
--color-text-dim: #a3a3a3;
--color-muted: #404040;
--color-border: #2a2a2a;
--color-cyan: #06b6d4;
--color-purple: #a855f7;
}
.light {
--color-bg: #f5f5f5;
--color-bg-dark: #e5e5e5;
--color-bg-panel: #ffffff;
--color-bg-card: #fafafa;
--color-primary: #ea580c;
--color-primary-dim: #c2410c;
--color-accent: #16a34a;
--color-accent-dim: #15803d;
--color-danger: #dc2626;
--color-danger-dim: #b91c1c;
--color-warning: #ca8a04;
--color-text: #171717;
--color-text-dim: #525252;
--color-muted: #d4d4d4;
--color-border: #e5e5e5;
--color-cyan: #0891b2;
--color-purple: #9333ea;
}
Keep the @theme block referencing these variables so Tailwind can resolve them.
3. Update layout.tsx
- Create a
ThemeProvider client wrapper component at src/components/providers/ThemeProvider.tsx
- Wrap children in
<ThemeProvider attribute="class" defaultTheme="dark">
- Add
suppressHydrationWarning to <html>
4. Create theme toggle
Add a toggle component at src/components/ui/ThemeToggle.tsx using useTheme() from next-themes. Match the existing retro pixel aesthetic — use a simple sun/moon icon or text label like [LIGHT] / [DARK].
5. Place the toggle
Add <ThemeToggle /> to the Navbar component at src/components/layout/Navbar.tsx.
Light theme guidelines
- Maintain the retro hacker feel — use slightly warm grays, not pure white
- Keep glow effects subtle in light mode (reduce opacity/spread)
- CRT scanline overlay should reduce opacity in light mode
- Pixel borders should remain visible with adjusted contrast
- The primary orange and accent green should darken slightly for readability on light backgrounds
Key files
src/app/globals.css — color palette definition
src/app/layout.tsx — theme provider wrapping
src/components/layout/Navbar.tsx — toggle placement
src/components/layout/ScanlineOverlay.tsx — may need opacity adjustment