🎨

Dark Mode Implementation Guide

Add a complete dark mode system to an existing Next.js app

Beginner🎨 FrontendAll Models
prompt template
Add dark mode support to my Next.js app that uses Tailwind CSS.

Current setup:
- Next.js App Router with TypeScript
- Tailwind CSS for styling
- No existing theme system

Implement the following:
1. **Theme provider** using React context that:
   - Defaults to system preference (prefers-color-scheme)
   - Allows manual toggle (light / dark / system)
   - Persists choice in localStorage
   - Avoids flash of wrong theme on page load (use a script in <head>)

2. **Toggle component** — a clean button/switch for the navbar

3. **CSS strategy** — show how to define color tokens that swap between themes using Tailwind's dark: variant or CSS variables

4. **Migration checklist** — list the steps to convert existing components (what to search for, what to replace)

Provide the complete implementation files. Use no external theme libraries.

How to Use This Prompt

  1. 1Copy the prompt template above
  2. 2Paste into Claude, ChatGPT, or Cursor
  3. 3Replace [bracketed placeholders] with your specific project details
  4. 4Iterate on the AI output to refine and customize the results