Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Setup & site building · Guide

How to Add a Dark Mode to a WordPress Site

How to Add a Dark Mode to a WordPress Site

Short answer

To add dark mode to a WordPress site, install the WP Dark Mode plugin and turn on front-end dark mode, or add a prefers-color-scheme media query to your CSS that swaps light colors for dark ones. The plugin adds a toggle button and follows the visitor's device setting. The CSS route follows the device setting with no toggle.

Key takeaways

  • WordPress has no built-in dark mode for the front end of a site.
  • WP Dark Mode was updated on 28 October 2026 and holds a 4.5 out of 5 rating from 391 reviews.
  • The prefers-color-scheme media query follows the visitor's light or dark device setting.
  • Block themes store colors as CSS variables, which you can overwrite inside a dark media query.
  • Use dark gray backgrounds with light gray text, since pure black and pure white can glare.

What is dark mode on a WordPress site?

Dark mode is a light-on-dark color scheme for your site, where text and icons sit on dark backgrounds instead of white ones.

Visitors who set their device to dark mode expect sites to follow that choice, and a site that stays bright white can feel harsh late at night. Dark mode flips the palette: dark backgrounds, light text, and softer link and button colors.

The content stays the same, and only the colors change.

There are two parts to a good dark mode. The first is automatic: the site follows the visitor's device setting without them doing anything.

The second is manual: a toggle button lets a visitor pick light or dark for themselves. A site with both parts covers the most visitors.

Does WordPress have a built-in dark mode?

No, WordPress has no built-in dark mode for the front end of a site, so you add it with a plugin or with custom CSS.

A WordPress.org support thread on dark mode states this plainly: there is currently no functionality in WordPress for setting a separate color scheme for dark mode.

The answer in that thread, from the theme author Anders Noren, adds that a plugin could do it, and that block themes offer a CSS route instead.

That CSS route works because block themes use CSS variables for colors. The same thread shows custom CSS that overwrites those variables inside a media query for devices set to dark mode. You can add that CSS through the Customizer's Additional CSS panel, or through a custom CSS plugin.

Your theme may also ship its own dark mode. Check “Appearance”, then “Customize” on a classic theme, or your theme settings panel, before you install anything. If the theme already has a toggle, use it instead of adding a second one.

How do you add dark mode with the WP Dark Mode plugin?

Install the WP Dark Mode plugin, turn on front-end dark mode in its settings, and pick a switch style for the floating toggle button.

WP Dark Mode is listed on WordPress.org, and its plugin page shows it was updated on 28 October 2026 with a rating of 4.5 out of 5 from 391 reviews.

Its page says you can create a dark mode version of your site without any setup, and that it follows the visitor's operating system preference.

Follow these steps:

  1. Go to “Plugins”, then “Add New”, and search for “WP Dark Mode”.
  2. Click “Install Now”, then “Activate”.
  3. Open “WP Dark Mode”, then “Settings” in the dashboard menu.
  4. Turn on “Enable Frontend Dark Mode”.
  5. Pick a floating switch style and a position for the toggle, such as bottom right.
  6. Turn on “Match OS Dark Mode” if you want the plugin to follow the visitor's device setting.
  7. Save the settings and check the site in a private window.

The plugin's page lists the free features: a floating dark mode switch, a default dark mode option, a switch that follows the device setting, an admin panel dark mode, and 2 color presets.

It also lists a shortcode to place the switch anywhere, and a setting that remembers each visitor's choice. Its paid Ultimate version adds 21 floating switch styles, 13 more color presets and a sunset-based automatic mode.

The plugin also supports a Gutenberg block and an Elementor widget for the switch, so you can place the toggle in a header or a page instead of floating it.

Its keyboard shortcut is “Ctrl+Alt+D”, and its shortcode is “[wp_dark_mode_switch]”. The page says it works across Windows, Android, iOS and macOS.

How do you add dark mode with CSS only?

Add a media query for dark mode to your CSS that swaps your light colors for dark ones when the visitor's device uses a dark scheme.

MDN's prefers-color-scheme guide explains the media feature: the value “dark” means the user has said they prefer a dark theme, and “light” means they prefer a light theme or have not said otherwise. The usual pattern is a light scheme by default, with a dark override inside the media query.

Here is a small example for a classic theme:

@media (prefers-color-scheme: dark) {
  body {
    background: #121212;
    color: #e0e0e0;
  }
  a {
    color: #64b5f6;
  }
  img {
    opacity: 0.9;
  }
}

Add that CSS under “Appearance”, then “Customize”, then “Additional CSS” on a classic theme. On a block theme, the Customizer link is hidden, but you can still open it at “/wp-admin/customize.php”, as the WordPress.org support thread notes.

For a block theme, the cleaner route is to overwrite the theme's CSS variables. The same support thread shows this pattern:

@media (prefers-color-scheme: dark) {
  body {
    --wp--preset--color--foreground: #1D201F;
    --wp--preset--color--background: #fff;
    --wp--preset--color--primary: #FFDE0D;
  }
}

Change those variable values to your own colors. The thread notes you can change the variables to whatever colors you want, and the theme will use them on devices with dark mode active. For more on how those variables work, see how to use theme.json.

web.dev's theming guide shows the same idea with CSS custom properties: store each color once, then change the values inside the media query instead of repeating every selector.

How do you add a manual toggle without a plugin?

Add a toggle button that swaps a class on the page, store the visitor's choice in the browser, and style that class with dark colors.

The CSS-only route has one limit: it follows the device setting and gives the visitor no choice. A manual toggle fixes that, but it needs a small script. The idea has three parts, and each part is simple on its own.

First, add a button to your header or footer, such as a button labelled “Dark mode”. On a block theme, add it with a Custom HTML block or through your theme's header template. See how to edit the header in a block theme for where that block lives.

Second, add a script that toggles a class such as “dark” on the body element when the button is clicked, and saves the choice in local storage so the next visit remembers it.

Third, add CSS that styles the page when that class is present, such as dark backgrounds and light text.

This route gives you full control over the colors, but it also gives you full responsibility for the code. If you are not at ease with JavaScript, use the plugin route instead. A plugin also handles edge cases such as images that stay too bright in dark mode.

How do you darken the WordPress admin area?

Turn on the admin dark mode option in your dark mode plugin, or use the “Enable Backend Darkmode” setting in WP Dark Mode.

WP Dark Mode's plugin page lists an admin panel dark mode among its features, and says it gives your eyes a rest while you work long hours in the dashboard.

That is a separate switch from the front-end mode, so you can darken the admin area even if the public site stays light.

Darkening the admin area only changes what logged-in users see, so it never affects visitors. It is a personal comfort setting, not a site design choice, and each admin can pick their own preference.

If you use the CSS-only route, the admin area stays light unless you add admin CSS too. A plugin is the simpler path here, since it already ships the admin switch and you do not need to write code for a screen only your team sees.

How do you pick dark colors that stay readable?

Pick a dark gray background instead of pure black, use light gray text instead of pure white, and check the contrast before you publish.

Pure black behind pure white text can glare, and it can make long pages tiring to read. A dark gray such as “#121212” with light gray text such as “#e0e0e0” is softer.

Links need a lighter color in dark mode too, since a dark blue link can vanish on a dark background.

This table shows the pairings from the example above:

ElementLight modeDark mode
Body backgroundWhite#121212 dark gray
Body textDark gray#e0e0e0 light gray
LinksDark blue#64b5f6 light blue
ImagesFull opacity0.9 opacity

Check these three things before you publish:

  • Body text has enough contrast against the background on every template, including single posts and archive pages.
  • Buttons keep their text readable in both modes, since a button that looks fine in light mode can wash out in dark mode.
  • Images and logos still read well. A dark logo on a dark background disappears, so check your header in both modes.

MDN's prefers-color-scheme guide is built on the Media Queries Level 5 specification, which defines the light and dark values browsers use. That shared definition is why the same media query works across browsers and devices.

How do you check dark mode on phones and desktops?

Switch your own device to dark mode, open the site in a private window, and read several pages on a phone and on a desktop.

Follow these steps:

  1. Turn on dark mode in your phone or computer settings.
  2. Open your site in a private window so no old cache hides the change.
  3. Read the home page, a single post and an archive page in dark mode.
  4. Flip the manual toggle, if you have one, and confirm it switches the site back to light mode.
  5. Reload the page and confirm the choice sticks, since the plugin or script should remember it.

Check the places that break most often: the header logo, the menu, form fields, buttons, and any image with a white background. A logo made for a white header is the most common failure, so keep a version that works on dark backgrounds.

Test on at least one phone and one desktop. A toggle that works on a desktop browser can sit under a thumb or off screen on a phone, so check the switch position on a small screen too.

Block theme vs classic theme explains which editor your theme uses, and that decides where your toggle code lives.

What mistakes should you avoid?

Avoid shipping dark mode that only changes the background, and avoid a toggle that does not remember the visitor's choice.

Watch out for these common mistakes:

  • Changing only the body background and leaving the header, footer and sidebar white. Visitors see a half-dark site, which looks broken.
  • Using pure black and pure white together. The contrast glares, so use dark gray and light gray instead.
  • Forgetting form fields, buttons and links. A dark input with dark text is unusable, so style those parts too.
  • Adding two dark mode tools at once. A plugin and custom CSS can fight each other, so pick one route and stick to it.
  • Skipping the phone check. A floating switch that covers content on a small screen will annoy the visitors you most want to keep.

Start with the automatic CSS route if you only need the site to follow device settings. Add a plugin when you want a toggle, an admin dark mode, or presets without writing code.

Frequently asked questions

Does WordPress have a dark mode setting?

No, WordPress has no built-in dark mode for the front end. A WordPress.org support thread states there is currently no functionality for setting a separate dark color scheme. You add dark mode with a plugin, or with custom CSS that follows the visitor's device setting.

What is the easiest way to add dark mode to WordPress?

Install the WP Dark Mode plugin, turn on front-end dark mode, and pick a switch style for the floating toggle. Turn on the option to match the visitor's operating system setting so the site follows their device choice without them doing anything.

How do I add dark mode with CSS only?

Add a media query for prefers-color-scheme: dark to your CSS, and set dark background and light text colors inside it. On a block theme, overwrite the theme's CSS variables instead. Add the CSS under Appearance, then Customize, then Additional CSS.

Can I add a manual dark mode toggle without a plugin?

Yes. Add a button that toggles a class on the page, save the visitor's choice in the browser, and style that class with dark colors. This gives you full control, but you write and keep the code yourself, so use a plugin if you prefer not to.

Can I darken the WordPress admin area too?

Yes. WP Dark Mode lists an admin panel dark mode among its features, with its own switch in the plugin settings. That only changes what logged-in users see, so it never affects visitors on the public site.

Sources

  1. WP Dark Mode WordPress.org
  2. Dark mode (support thread) WordPress.org
  3. prefers-color-scheme CSS media feature MDN
  4. Theming web.dev
  5. Media Queries Level 5 W3C

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.