Dark Mode Generator

πŸ“– Learn More

Related Guide How to Build Dark Mode with CSS β†’

What Is Dark Mode Generator?

Dark Mode Generator lets you set six colour tokens (background, surface, border, two text colours and an accent) for a light and a dark theme, checks the WCAG contrast of each text pair in both themes, and writes the CSS custom properties with color-scheme for system-following, toggle-driven or combined switching. You pick the dark colours; it does not derive them from the light ones.

How to Use This Tool

Switch between the Light and Dark tabs and edit each colour (picker or hex). The preview shows the theme you are editing; the contrast table shows both themes at once, flagging any pair below its WCAG target. Choose how the theme switches (system setting, a data-theme toggle, or both) and copy the CSS. Everything runs in your browser.

Why Use Dark Mode Generator?

A dark theme that works needs every text and accent colour checked again on the dark surfaces, plus switching CSS that respects both the system setting and a reader's own choice. The contrast table and the combined output cover both. It’s free, with no design tool subscription needed. For a detailed walkthrough, see our step-by-step guide.

Common Use Cases

Adding dark-mode support to an existing site that hard-codes light colors throughout, without a token-by-token audit. Bootstrapping the theming layer for a new design system where light and dark variants need to share the same CSS-variable spine. Auditing your current palette's dark-mode behavior — some light-mode colors look fine inverted, others (saturated yellows, pale greens) need bespoke darker variants to stay legible.

Migrating a brand redesign through both modes simultaneously, so the dark variant doesn't become a last-minute "just invert everything" pass that breaks contrast on important UI states. Generating a starter :root + [data-theme="dark"] block you can drop into a fresh stylesheet and refine. Building parallel light and dark previews for stakeholder review so decisions about brand colors happen once, against both modes, instead of re-litigating dark mode three weeks after the light variant ships.

Worked example: the default palettes, measured

On October 12, 2026 we checked every default colour against the background and the surface with the WCAG contrast formula, and loaded the generated CSS in Chromium with the system set to dark.

ColourLight: on bg / on surfaceDark: on bg / on surface
Text primary17.06 / 15.6515.34 / 13.43
Text secondary4.83 / 4.437.38 / 6.46
Accent (as link text)3.68 / 3.377.37 / 6.45
Border1.32 / 1.211.34 / 1.17

Frequently Asked Questions

How does prefers-color-scheme work?+
The prefers-color-scheme CSS media feature detects whether the user has set their operating system to light or dark mode. You can use it to automatically apply the appropriate theme without requiring a manual toggle.
Should I use CSS variables for theming?+
Yes. CSS custom properties (variables) are the recommended approach for dark mode. Define color tokens on :root for light mode and override them inside a prefers-color-scheme: dark media query or a .dark class.
What colors work well for dark mode?+
A dark grey background such as #121212 (Material Design's dark surface) rather than pure black, primary text around 87% white (14.19:1 on #121212) and secondary around 60% (7.16:1), and accents re-picked for the dark background: a blue that passes on white can fail on dark and vice versa, which the contrast table shows.
How do I add a manual dark mode toggle?+
Set data-theme="dark" or data-theme="light" on the html element from a small script, and write the dark tokens under :root[data-theme="dark"]. To let the toggle override the system setting both ways, use the generator's Both output: the media query applies only to :root:not([data-theme="light"]), and light and dark toggle rules set color-scheme to match.
Should I use prefers-color-scheme or a manual toggle?+
Both, ideally: follow the system by default and let a toggle override it. The generator outputs either pattern alone or the combined Both version.
How do I avoid the white-flash on page load?+
Read the stored choice from localStorage in a tiny inline script in the <head> and set data-theme before the stylesheet paints. The generator outputs the CSS only; the script is a few lines you add yourself.
Will my images need a dark-mode treatment?+
Often, yes. Photos generally don't need adjustment; SVG icons with hard-coded colours and screenshots with white backgrounds do. Use currentColor in SVGs, or serve alternate images with <picture> and a prefers-color-scheme media attribute. The generator itself does not process images.
Does the generator handle WCAG contrast for both modes?+
Yes. The contrast table lists text, secondary text and the accent against the background and the surface for both themes, as ratios truncated to two decimals, and marks anything below 4.5:1 (borders below 3:1). It does not change your colours for you.

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service