c/frontend › command
0votes

Universal Dark-Mode Toggle

PromptLow risk
submitted by CommandVault editors to c/frontend · 8 uses

Persist a user’s light/dark preference across sessions and devices.

Prompt · 2 variables
Add a light/dark theme toggle that remembers each person's choice.

Stack: {{stack}}
Default for new visitors: {{goal}}

Requirements:
1. Three options: Light, Dark and System. Apply the default above until someone chooses.
2. Save the choice in localStorage, and in the user's profile when they're logged in, so it follows them across devices.
3. Apply the theme before first paint (an inline script or server-rendered class), so there's no flash of the wrong theme.
4. Drive colors from CSS variables, and check text contrast meets WCAG AA in both themes.
5. The toggle must be a real button with an accessible name and the current state announced.

List the files you'll change, then give me a test checklist: first visit, switch and reload, log in on a second browser, and system theme changes.
e.g. 'follow the system setting' or 'always light first'
Framework, language and versions, e.g. Next.js 16 App Router + TypeScript
0 commentsreport

Try it here

Fill in {{goal}} above first for a better answer, or run it as is and the AI will assume sensible values.

or open in ChatGPT · Claude · Perplexity

How to use this prompt

  1. Fill in the 2 blanks above. The more specific you are, the better the answer.
  2. Copy it and paste it into ChatGPT, Claude, Gemini, Cursor or Codex, or use "Try it here" for a quick test.
  3. Read the answer critically: check anything it claims about your code or data before you rely on it.
  • {{goal}} e.g. 'follow the system setting' or 'always light first'
  • {{stack}} Framework, language and versions, e.g. Next.js 16 App Router + TypeScript

More from c/frontend

See all of c/frontend →
0 comments

Log in to join the discussion.