Skip to content

WordPress Dark Mode: How to Add a Site-Wide Light/Dark Toggle (With and Without Elementor)

Key Takeaways

  • WP Dark Mode is closed on the official WordPress.org plugin directory since August 5, 2026, pending a review, so fresh downloads are not available even though existing installs still work.
  • A site-wide dark mode toggle needs three pieces: a dark CSS palette, a stored preference via localStorage or a cookie, and an instant switch mechanism that toggles a class on the or element before the page paints.
  • The prefers-color-scheme media query matches the visitor’s operating system setting at no cost and with no plugin, but it does not provide a manual toggle for users who want to override their OS choice.
  • Elementor sites can build a custom dark mode toggle without a dedicated plugin by adding an icon or switch in the header, giving it a unique CSS ID such as dark-toggle, and using JavaScript to toggle body.dark-mode and save the state to localStorage.

I went looking for a dark mode plugin to recommend in this guide and found that the one most sites actually use, WP Dark Mode, has been closed on the official WordPress.org plugin directory since August 5, 2026, pending a review. It is not deleted, existing installs still work, but nobody can download it fresh right now. That is an unusual thing to happen to a plugin with tens of thousands of installs, and it is exactly the kind of single point of failure worth knowing about before you build a feature around one plugin.

This guide covers what a real site-wide dark mode toggle actually requires, the current state of the WordPress plugin options, and how to add one with or without Elementor.

Table Of Contents

What a Site-Wide Dark Mode Toggle Actually Needs

A working light/dark toggle is three separate pieces working together, not one setting:

  • A dark CSS palette. Every background, text, border, and image needs a dark-mode counterpart, usually written as CSS custom properties (variables) so you can swap the whole set at once.
  • A stored preference. The visitor’s choice needs to persist across pages and return visits, typically via localStorage or a cookie, so they do not have to re-toggle it on every page load.
  • An instant switch mechanism. Toggling a class on the <html> or <body> element that the CSS palette responds to, applied before the page paints to avoid a flash of the wrong theme.

Miss the third piece and you get the common “flash of light mode” bug where a returning dark-mode visitor sees a half-second of white background before JavaScript kicks in.

Method 1: The Native Browser Preference (Zero Plugins)

The CSS prefers-color-scheme media query lets your stylesheet automatically match whatever light or dark setting the visitor has already chosen in their own operating system:

@media (prefers-color-scheme: dark) {
  body { background: #121212; color: #e0e0e0; }
}

This costs nothing, needs no plugin, and respects the visitor’s system-level choice. Its limitation is that there is no manual toggle switch. A visitor whose OS is set to light mode but who personally prefers a dark website has no way to override it, which is why most sites still add an explicit on-page switch on top of this baseline.

Wordpress. Org plugin page showing the wp dark mode plugin closed pending review
The popular WP Dark Mode plugin was closed on WordPress.org pending review as of August 2026.

Method 2: A Dedicated Dark Mode Plugin

Dedicated dark mode plugins add a floating toggle button, an admin-configurable color palette, and localStorage handling without you writing any code. The catch right now is fragmentation: with WP Dark Mode closed pending review, the remaining active alternatives on WordPress.org (Dark Mode Toggle, Darklup, Darkify, Dark Mode for WP Dashboard) each sit at roughly 700 to 3,000 active installs, well short of a single dominant, battle-tested option. One older entrant, Dark Mode for Elementor, was closed permanently back in December 2023 for a guideline violation, so check a plugin’s last-updated date and active-install count before you commit to it, not just its name.

Method 3: A Theme or Page Builder’s Built-In Dark Mode

Some WordPress themes ship a dark mode toggle natively in their customizer, and it is worth checking Appearance > Customize before installing anything. This is usually the cleanest option when it exists, because the theme author already wrote dark-mode CSS for every one of that theme’s own components, which a generic plugin cannot guarantee.

Method 4: A Custom Toggle Built With Elementor + a Few Lines of JS

On a site already built in Elementor, you do not need a dedicated plugin at all for a basic toggle. Add an icon or switch as an Elementor button widget in your header, give it a unique CSS ID (for example dark-toggle), then add a small custom JavaScript snippet (via Elementor’s own custom code area, or a code snippets plugin) that toggles a dark-mode class on document.body and saves the state to localStorage. Your dark CSS palette then targets body.dark-mode for every color override.

This keeps the feature entirely inside your existing Elementor build with no new plugin dependency, at the cost of writing (or copying) a small amount of code yourself instead of getting an admin settings panel for free.

Which Method Should You Actually Use?

MethodManual toggleNew plugin dependencyBest for
prefers-color-scheme onlyNoNoZero-effort baseline, no admin control needed
Dedicated dark mode pluginYesYes (check install count first)Non-developers who want an admin settings panel
Theme’s built-in dark modeUsuallyNoThemes that already ship one; check first
Custom Elementor toggle + JSYesNoElementor sites wanting no extra plugin weight

Suggested Reading

Related Frequently Asked Questions

Why does a WordPress dark mode toggle need more than just a color switch?

A real site-wide toggle needs three parts working together: a dark CSS palette, a stored preference, and an instant switch mechanism. The palette handles backgrounds, text, borders, and images. The saved preference usually lives in localStorage or a cookie so visitors do not have to re-toggle on every page load. The instant switch matters because it prevents the common flash of light mode when JavaScript applies the theme too late.

Why is the native browser dark mode preference not enough for most sites?

The prefers-color-scheme media query is the lowest-effort baseline because it follows the visitor’s operating system setting and needs no plugin. The limitation is control: there is no manual toggle, so someone whose OS is set to light mode cannot force a dark website if they want one. That is why many sites use it as a starting point and still add an explicit on-page switch for user choice.

What are the risks of using a dedicated dark mode plugin on WordPress right now?

The main risk is plugin fragmentation. WP Dark Mode was closed on WordPress.org pending review as of August 2026, and the remaining active alternatives mentioned here sit at roughly 700 to 3,000 active installs each. That means there is no single dominant option to lean on. A practical check is to look at both the last-updated date and active-install count before committing to one.

What should I check before installing a theme dark mode toggle?

Appearance > Customize is the first place to look because some themes already ship a built-in dark mode toggle. That matters because the theme author has already written dark-mode CSS for that theme’s own components, which generic plugins cannot guarantee. If the theme includes it, that is usually cleaner than layering another plugin on top of existing styles.

How do I add a site-wide dark mode toggle in Elementor without another plugin?

A basic Elementor setup can do this with an icon or switch in the header, a unique CSS ID such as dark-toggle, and a small JavaScript snippet that toggles a dark-mode class on document.body while saving state to localStorage. The CSS then targets body.dark-mode for color overrides. The upside is no extra plugin dependency; the tradeoff is writing or copying a little code instead of using an admin panel.

Which WordPress dark mode method should I use for an Elementor site?

For an Elementor site that wants no extra plugin weight, the custom Elementor toggle plus JavaScript is the cleanest fit. If you want zero-effort baseline behavior with no manual control, prefers-color-scheme works. Dedicated plugins make sense when you want an admin settings panel and do not want code, but the page notes that install counts are still relatively small compared with older options.

Last reviewed: September 8, 2026