REIGN
Get Reign

Make any plugin follow Reign dark mode (Map a plugin's colours to Reign tokens)

How to make a plugin that Reign does not cover switch with your light and dark mode, by pointing its colours at Reign's colour tokens.

Also called: dark mode for a third-party plugin, plugin looks white in dark mode, plugin text unreadable in dark mode, map colours, Reign tokens, CSS variables.

What this does

Reign switches dark mode for the plugins it supports. See Other plugins that follow your colours and dark mode for the list. Any other plugin keeps its own colours, so it can stay white on a dark page. This guide shows how to fix that yourself in a few lines of CSS, for any plugin.

Reign does not ship CSS for every plugin. Thousands exist, and each one changes its own class names. What Reign gives you is a fixed set of colour tokens that already change with the mode. You point the plugin’s colours at them.

How Reign signals dark mode

When a visitor switches to dark mode, Reign sets data-bx-mode="dark" on the <html> element. In light mode the attribute is missing or light. Your CSS reads it like this:

html[data-bx-mode='dark'] .some-plugin-wrapper {
	background: var(--reign-site-sections-bg-color);
}

The colour tokens to use

Use these. Each one holds a light value in light mode and a dark value in dark mode, so one rule covers both.

TokenUse it for
--reign-site-body-bg-colorThe page behind everything
--reign-site-sections-bg-colorCards, panels and boxes on the page
--reign-site-secondary-bg-colorA second surface: table stripes, hover rows, code blocks
--reign-site-body-text-colorNormal text
--reign-site-headings-colorHeadings and strong text
--reign-site-alternate-text-colorMuted text: dates, hints, captions
--reign-site-link-colorLinks
--reign-site-link-hover-colorLinks on hover
--reign-site-border-colorBorders and dividers
--reign-colors-themeYour Theme Color, for accents and active states
--reign-site-button-bg-color, --reign-site-button-text-colorPrimary buttons
--reign-site-button-bg-hover-color, --reign-site-button-text-hover-colorPrimary buttons on hover
--reign-form-background-color, --reign-form-text-color, --reign-form-border-colorText fields, selects and text areas

Never copy the hex values. They change when you change your palette or your Dark Mode Colors, and a copied value stops following.

Steps

Find which case your plugin is. Open its page, press F12, select the part that stays white, and look at the Styles panel.

Case 1: the plugin uses its own CSS variables

Most modern plugins draw their colours from variables such as --plugin-card-bg. Set those variables, in dark mode only, to Reign tokens. Reign does this for FluentCart. The pattern is:

html[data-bx-mode='dark'] {
	--plugin-card-bg: var(--reign-site-sections-bg-color);
	--plugin-text: var(--reign-site-body-text-color);
	--plugin-muted: var(--reign-site-alternate-text-color);
	--plugin-border: var(--reign-site-border-color);
}

To find the variable names, select an element, look in Styles for a value written var(--...), and click the variable to see where it is set.

Case 2: the plugin has its own dark setting or class

Some plugins ship a dark theme, set in their own settings or by a class such as .dark. Use that first, since it is designed by the plugin author. Note that a plugin setting follows the plugin, not the visitor’s Reign switch. If the plugin only offers a fixed “dark” choice, it cannot follow the switch, and Case 3 is the better fit.

Case 3: the plugin uses fixed colours

If the colours are written straight into its CSS, write a small scoped rule for the plugin’s outer wrapper, for dark mode only. Keep the rules few and target the wrapper class, never a bare element:

html[data-bx-mode='dark'] .some-plugin-wrapper {
	background: var(--reign-site-sections-bg-color);
	color: var(--reign-site-body-text-color);
	border-color: var(--reign-site-border-color);
}

html[data-bx-mode='dark'] .some-plugin-wrapper a {
	color: var(--reign-site-link-color);
}

Where to put the CSS

  • For a few rules, go to Appearance > Customize > Additional CSS and paste them there.
  • For a larger set, put them in your child theme style.css, so they stay with your code.

You’ll know it worked when

Switch your site to dark mode with the sun and moon button. The plugin’s panels, text and fields use dark surfaces and light text. Switch back to light mode and the plugin looks as it did before, because every rule above applies to dark mode only.

Check three things before you call it done:

  1. Both modes, on every screen of the plugin you use.
  2. A phone width of 390 pixels.
  3. Text against its background is easy to read. Muted text is the usual problem.

Good to know

What cannot be fixed with CSS

  • Content inside an iframe or a shadow DOM cannot be reached from your site’s CSS. The plugin has to provide its own dark option.
  • A plugin update can rename its classes and variables, and your rules then stop matching. Re-check after major plugin updates.
  • Charts, maps and embedded media draw their colours inside the plugin and usually need the plugin’s own settings.

When this is too much

If a plugin needs more than a handful of rules, or a client needs it to be exact, that is custom development. Contact Wbcom Designs for a quote.