# Example: High Start (Level 4) Clear request with context — minimal clarification needed, fast to delivery. I need to add a dark mode toggle to my Next.js app. I'm using Tailwind CSS and want to persist the preference in localStorage. Should work with system preference as a default. ```text [Task] Clear requirements — fast path - Clarify implementation details (in_progress) - Deliver dark mode implementation (pending) ``` ```text ▓▓▓▓░ Mapped You've given me most of what I need: - Next.js + Tailwind CSS - Toggle component - localStorage persistence - System preference default Assumptions: - Tailwind's built-in dark mode (class strategy) - Client-side toggle (no server preference) - Standard light/dark, no custom themes Decisions: - Dark mode with localStorage + system fallback - Tailwind class strategy - Toggle UI component ``` Can deliver now, or one quick question: where does the toggle live? (header, settings page, floating button) [★] If you just want the implementation and will place it yourself, I can skip that question. ```text [EnterPlanMode] 1. Skip — just give me the implementation 2. Header/navbar — always visible 3. Settings page — dedicated settings area 4. Floating button — corner of screen 5. Something else — different placement ``` 1, I'll put it in my header ```text ▓▓▓▓▓ Ready All clear — delivering implementation. ``` ```text [Task] Delivering - Clarify implementation details (completed) - Deliver dark mode implementation (in_progress) ``` ## Dark Mode Implementation **1. Configure Tailwind** (`tailwind.config.js`): ```javascript module.exports = { darkMode: 'class', // ... rest of config } ``` **2. Theme Provider** (`components/theme-provider.tsx`): ```typescript 'use client'; import { createContext, useContext, useEffect, useState } from 'react'; type Theme = 'light' | 'dark' | 'system'; const ThemeContext = createContext<{ theme: Theme; setTheme: (theme: Theme) => void; }>({ theme: 'system', setTheme: () => {} }); export function ThemeProvider({ children }: { children: React.ReactNode }) { const [theme, setTheme] = useState('system'); useEffect(() => { const stored = localStorage.getItem('theme') as Theme | null; if (stored) setTheme(stored); }, []); useEffect(() => { const root = document.documentElement; const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches; root.classList.remove('light', 'dark'); if (theme === 'system') { root.classList.add(systemDark ? 'dark' : 'light'); } else { root.classList.add(theme); } localStorage.setItem('theme', theme); }, [theme]); // Listen for system preference changes useEffect(() => { const media = window.matchMedia('(prefers-color-scheme: dark)'); const handler = () => { if (theme === 'system') { document.documentElement.classList.remove('light', 'dark'); document.documentElement.classList.add(media.matches ? 'dark' : 'light'); } }; media.addEventListener('change', handler); return () => media.removeEventListener('change', handler); }, [theme]); return ( {children} ); } export const useTheme = () => useContext(ThemeContext); ``` **3. Toggle Component** (`components/theme-toggle.tsx`): ```typescript 'use client'; import { useTheme } from './theme-provider'; import { Sun, Moon, Monitor } from 'lucide-react'; // or your icon library export function ThemeToggle() { const { theme, setTheme } = useTheme(); const cycle = () => { const next = theme === 'light' ? 'dark' : theme === 'dark' ? 'system' : 'light'; setTheme(next); }; return ( ); } ``` **4. Wrap App** (`app/layout.tsx`): ```typescript import { ThemeProvider } from '@/components/theme-provider'; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( {children} ); } ``` **5. Prevent Flash** (add to `` in layout): ```typescript