Light and dark theme generator (CSS variables)
Choose the primary color. The generator builds both palettes, checks the contrast of each pair and shows the preview side by side.
How to useDark mode from your brand color
Light and dark theme generator (CSS variables): what it is for
A well-made dark theme isn't the inverse of the light one. From your brand's primary color, the generator builds the CSS variables for both themes (background, surface, border, text, secondary text, primary color and the text on it) with neutral grays or grays tinted toward the brand color.
Each color pair has its contrast calculated with the WCAG formula and marked as AAA, AA or insufficient, and the primary color is adjusted to pass 4.5:1 in both themes. The code switches themes based on the system mode (prefers-color-scheme) and, if you like, also via a button with data-theme.
How to use
- Choose the primary color.
- Check the preview and the contrast table.
- Copy the CSS variables.
When to use it
- Creating a dark mode for a website.
- Building the palette for a new project.
- Checking color accessibility.
Frequently asked questions
Why isn't dark mode just inverting the colors?
Inverting makes the background pure black and the brand colors garish, which tires the eyes. A good dark theme uses a very dark gray background, near-white text and a lighter version of the primary color, to keep contrast without glare.
What do AA and AAA mean for contrast?
They're levels from the WCAG accessibility guidelines. AA requires a contrast of at least 4.5:1 for normal text; AAA, 7:1. The generator shows the ratio of each color pair and warns when any falls below 4.5:1.
How do I switch themes with a button?
The code responds to the system mode (prefers-color-scheme) and also to the data-theme attribute on html. A button that sets data-theme="dark" or "light" forces the chosen theme; this site's Dark mode toggle tool generates that button.
Is it really free?
Yes, 100% free. No sign-up, no subscription and no usage limits. All Tools123 tools are free and run right in your browser.