← All tools

CSS Dark Mode Generator

Edit light and dark CSS theme colors or derive a dark palette. Inspect text and border contrast before exporting.

css-dark-mode-generatorLOCAL WORKSPACE

Enabling local controls…

Theme workflow

Jump to preview and export

Settings

Light theme
Dark theme

Preview and export

Light theme

Account details

Changes take effect at your next sign-in.

View settings

Update available

Dark theme

Account details

Changes take effect at your next sign-in.

View settings

Update available

Light theme contrast · 10/10 pairs pass
Light theme contrast
Color pairRatioWCAG AA
Text / Background17.063:1PassNormal text 4.5:1
Text / Surface17.853:1PassNormal text 4.5:1
Muted text / Background7.243:1PassNormal text 4.5:1
Muted text / Surface7.578:1PassNormal text 4.5:1
Primary / Background7.554:1PassNormal text 4.5:1
Primary / Surface7.903:1PassNormal text 4.5:1
Accent / Background5.231:1PassNormal text 4.5:1
Accent / Surface5.473:1PassNormal text 4.5:1
Border / Background4.548:1PassNon-text 3:1
Border / Surface4.759:1PassNon-text 3:1
Dark theme contrast · 10/10 pairs pass
Dark theme contrast
Color pairRatioWCAG AA
Text / Background17.063:1PassNormal text 4.5:1
Text / Surface13.982:1PassNormal text 4.5:1
Muted text / Background12.024:1PassNormal text 4.5:1
Muted text / Surface9.853:1PassNormal text 4.5:1
Primary / Background8.955:1PassNormal text 4.5:1
Primary / Surface7.338:1PassNormal text 4.5:1
Accent / Background12.068:1PassNormal text 4.5:1
Accent / Surface9.889:1PassNormal text 4.5:1
Border / Background6.963:1PassNon-text 3:1
Border / Surface5.705:1PassNon-text 3:1

Add the stylesheet to your site and apply the colors with var(--color-*). The device preference applies by default and the root data-theme attribute overrides it.

To offer a theme selector, place the HTML control on your page and load the optional script in the head. It stores the visitor’s selection on your own site.

CSS

:root {
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #475569;
  --color-primary: #4338ca;
  --color-border: #64748b;
  --color-accent: #0f766e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-background: #0f172a;
    --color-surface: #1e293b;
    --color-text: #f8fafc;
    --color-muted: #cbd5e1;
    --color-primary: #a5b4fc;
    --color-border: #94a3b8;
    --color-accent: #5eead4;
  }
}

:root[data-theme="dark"] {
  --color-background: #0f172a;
  --color-surface: #1e293b;
  --color-text: #f8fafc;
  --color-muted: #cbd5e1;
  --color-primary: #a5b4fc;
  --color-border: #94a3b8;
  --color-accent: #5eead4;
}

:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
Download CSS

How to use this tool

Edit HEX values or load a preset, compare the two themes, and export CSS, JSON or a standalone theme selector.

When not to use it

Derived colors are starting points. Contrast covers solid color pairs shown in the report. The tool holds edits in the page; the optional exported script can store a preference on your site.

Read the guide →