Skip to main content

Claude Prompt to Implement a Dark Mode System

Implement a dark mode system with CSS custom property tokens, smooth transitions, system preference detection and persistent user choice, no flash.

Füllen Sie die Platzhalter aus

Edit the values, then copy your finished prompt.

Ihr Prompt
prompt.txt

                                

What this prompt does

This prompt implements a complete dark mode system for a [framework] app with [component_count] components, built on CSS custom properties rather than scattered overrides. It starts with a semantic token architecture, mapping abstract names like --color-surface and --color-text-primary to concrete values, then derives a proper dark palette, wires up the toggle, handles images and transitions, and ends with a [component_framework] ThemeProvider. Building from semantic tokens means switching themes is a single source change, not a hunt through every component.

The variables encode the quality details that separate a real implementation from a hack. [token_count] sets how granular the token layer is, and [dark_selector] decides the activation strategy. Crucially, the prompt does not invert colors: [dark_surface_color], [dark_contrast_target], and [desaturation_amount] shape a comfortable dark palette. [toggle_approach] and [storage_method] handle the three-state light/dark/system choice and persistence, and the prompt explicitly applies the theme before first paint to kill the flash of wrong theme.

When to use it

  • Adding dark mode to an app that currently only ships a [current_theme] light theme.
  • Replacing a naive color-inversion hack with a proper desaturated dark palette.
  • Building a three-state toggle that respects manual choice, then system preference, then default.
  • Eliminating the flash of wrong theme on first paint with SSR-safe persistence.
  • Establishing a reusable semantic token layer across many components.
  • Handling images, logos, and SVG icons correctly in dark mode instead of dimming everything.

Example output

You get an implementation plan with code: a set of [token_count] CSS custom properties defined in :root and your [dark_selector], a derived dark palette using [dark_surface_color] with text at [dark_contrast_target] and vivid colors desaturated by [desaturation_amount], a toggle using [toggle_approach] persisting to [storage_method] with a pre-paint script, image and media strategies, [transition_duration] transitions on color properties (excluded on load), a validation checklist covering focus rings and autofill, and a ThemeProvider exposing a useTheme() hook.

Pro tips

  • Keep the token layer semantic; name tokens by role (--color-surface) not by value, so dark mode is a remap rather than a rewrite.
  • Use a near-black like the [dark_surface_color] default rather than pure #000; pure black creates harsh contrast and halo effects.
  • Tune [desaturation_amount] to taste; vivid brand colors that look great on white often glare on dark surfaces.
  • Apply the theme before first paint via an inline script; this is the single most important step for avoiding the flash.
  • Verify the [dark_contrast_target] against real text, especially secondary and muted tones, which are easy to push too dim.
  • Exclude code blocks and photos from the [transition_duration] transition so they do not flicker awkwardly during the switch.
  • Walk the validation checklist for focus rings, selection colors, scrollbars, and autofill backgrounds; these are the spots a dark theme quietly breaks.

Frequently Asked Questions

Why does the prompt say not to just invert colors?
Inverting produces harsh, oversaturated results and breaks brand consistency. Instead it uses a dark base surface, reduces text contrast for comfort, and desaturates vivid colors by `[desaturation_amount]`, which is how comfortable, professional dark themes are actually built.
How does it prevent the flash of the wrong theme?
It applies the stored or system theme before first paint, typically via an inline script that runs before the page renders. Combined with `[storage_method]` persistence and a cookie fallback for SSR, this avoids the white flash users see on reload.
Does it support a system-preference auto mode?
Yes. The `[toggle_approach]` includes a three-state choice: light, dark, and system auto. It reads `prefers-color-scheme` and respects a priority order where a manual choice overrides the system preference, which itself overrides the default.
Is it tied to a specific framework?
The token and toggle logic is framework-agnostic CSS and JavaScript, but the final ThemeProvider step targets `[component_framework]` (React by default). You can adapt the provider pattern to other frameworks while keeping the same CSS custom property architecture.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Mehr in Frontend Development Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support