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.
| Colour | Light: on bg / on surface | Dark: on bg / on surface |
|---|---|---|
| Text primary | 17.06 / 15.65 | 15.34 / 13.43 |
| Text secondary | 4.83 / 4.43 | 7.38 / 6.46 |
| Accent (as link text) | 3.68 / 3.37 | 7.37 / 6.45 |
| Border | 1.32 / 1.21 | 1.34 / 1.17 |
- Two light-mode defaults used to fail for body text (fixed October 13, 2026). Secondary text on the surface colour is 4.43:1 (needs 4.5), and the blue accent #3B82F6 is 3.68:1 on white, fine for large text and icons but not for links in a paragraph. #2563EB (5.17:1) is the next Tailwind step; the dark defaults all pass. The light defaults are now #4B5563 for secondary text (6.93:1 on the surface) and #2563EB for the accent (5.16:1), and the tool shows this table live for your own colours.
- Why the output now includes color-scheme. With only the generated variables, an <input> in dark mode kept a white background and black text in Chromium; adding
:root { color-scheme: light dark; }(or color-scheme: dark inside the dark block) switched it to a dark field with white text, and also darkens scrollbars. Every output now sets color-scheme in each theme. - prefers-color-scheme follows the system; Class toggle follows your attribute. The class version writes [data-theme="dark"] only, so it ignores the system setting until your script sets the attribute. A third option, Both, keeps the system default and lets data-theme="dark" or "light" override it either way (tested in Chromium: all six system/toggle combinations give the expected theme and form-control scheme). Set the attribute on load from localStorage, falling back to matchMedia('(prefers-color-scheme: dark)'), before the page paints to avoid a flash.
- Borders are decorative here. At about 1.3:1 they separate areas visually but would not meet the 3:1 non-text contrast for input borders; give form fields their own stronger border variable.
- Only bg and text-primary are wired up in the usage block; apply --color-surface, --color-border, --color-text-secondary and --color-accent to your components yourself.
Sources
Checked on .
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools