You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The site owner can't easily let visitors change the appearance of the site, which could improve accessibility. Think "high contrast" style or "dark mode". Also the theme styles are such a nice addition, but there's way more potential hidden behind a really simple block. Right now only the site owner can change the style, but the other styles stay "hidden" and inactive.
What is your proposed solution?
Add a simple toggle block which you could e.g. add to your site header, where you select one of your Theme Styles to toggle to. As soon as you click the toggle, the styles toggle to the chosen style. This way you can easily add a High Contrast style, Big Fonts style, Dark Mode style, etc. to your site, making it more accessible and/or providing a better user experience.
I’m shocked there isn’t a suitable plugin on the market to address this, given how smoothly Style Variations operate within the Site Editor (“Browse Styles” pane) and the growing client expectations on Dark Mode.
Considerations
The “Browse Styles” pane might include a way to designate light and dark Variations for prefers-color-scheme
This proposed “Toggle Styles” block could be a checkbox list to select your Variations for front-end rendering
If one Variation is picked, the “Toggle Styles” block renders as a basic toggle button (as OP suggests)
If multiple Variations are picked, then it might convert to a dropdown feature
Good afternoon
Please allow theme authors to publish their themes with theme switching blocks from dark to light (and vice versa) in the Wordpress repository.
This problem has been pointed out by one of the most popular authors of free themes for vordpress, Anders Noren
in this topic
I am sincerely convinced that Anders's opinion is worth listening to - he personally with his free themes has added to the worldwide popularity of Wordpress at least 1 percent of those 43% of the world's sites that run on Wordpress.
I recently came upon this variation style switcher block in this video. Looks like a pretty simple plugin that accomplishes the main feature in this suggested feature for block themes.
@dhanson-wp Tried the last plugin out with my custom styles and it did not work as expected. Also it creates an annoying menu in the backend instead of hiding.
Should this only support two design variants, or more?
I believe it should support any number and not be limited to something like dark vs. light mode.
I think the best course of action would be to integrate with the existing style variations system so that we're not introducing a new concept for themers to learn.
Under the hood, there's probably some things to work out with the way variations are stored. For example, users can't make per-variation style overrides, and style variations themselves are stored as user customizations (see: #62661).
Reminder:
It should automatically detect site visitors' preference through an OS setting or a user agent setting, or provide a way to work with prefers-color-scheme.
At first, I wanted this to become a core feature. However, after reading and discussing Rich Tabor's point above (#48249 (comment)), it's clear that this task is nearly impossible and needs to be handled on a per-site basis with a custom solution.
Not sure I understand why it can't be done. At least a theme switcher on UI.
Let's say I have Twenty-four child theme with light colors and a I make a second child theme with dark colors. If I add a button for users to click and it just switch themes, how difficult can that be?
I get that it light not be suitable if you use it with completely different theme architecture but that seems like an acceptable limitation to me.
Right now, the most ideal way I can think to do it would be to move toward a modern solution using the native CSS light-dark() function. But this would require an overhaul of how colors are handled in Global Styles, providing a mechanism for users to customize the colors for both light and dark mode. That's pretty much a prerequisite before even discussing a toggle block. Such a method assumes that the theme isn't already built with a custom design token system that goes beyond the current limitations of settings.color.palette.
Building it this way assumes we're building with the awareness that such features as schemed-value() could be a thing in the future and that light-dark() is just a stepping stone: w3c/csswg-drafts#9660
In the meantime, this is really something that theme authors can be implementing themselves in various ways. I'm pushing to get an article up on the Developer Blog in the next week that explains one method of doing it with modern CSS features.
But there are so many ways to tackle the same problem that I don't see a 100% clear path for Core. This is where exploration from theme authors is so crucial. Instead of just saying that we want something, we need to be sharing how we solved it and the feedback from real-world users on how it works.
I tried this one. But I had lots of difficulties to implement. That said, I'm developing my own theme and I suck at it. Could be might fault. But I got it work occasionally.
Amazing tutorial Justin.
As a theme creator, I'd use a very similar approach. I'm also inclined to use modern CSS so I'd love to be able to use light-dark() function paired with an interactive native block.
But for that strategy to be user friendly on the site editor, WordPress core would need to provide a mechanism for users to customize both light and dark mode colors, as Justin pointed out.
I'd love to see this implemented, I can't think of a better approach for this purpose.
This is a basic design token system. And it would allow users to customize the palette. However, it doesn't allow them to assign the light/dark colors to blocks. But it's another approach to colors themselves.
It's probably outside the scope of this specific ticket, but I'd love to see WordPress support a layered design token system (primitive -> semantic -> component). Otherwise, we end up with wildly different approaches to things like light/dark toggles, fixing one issue at the expense of another.
Activity
joedolson commentedon Aug 4, 2023
We discussed this in the accessibility bug scrub today, and think that this would be a great feature to standardize. A few questions to consider:
spacedragn commentedon Nov 28, 2023
I’m shocked there isn’t a suitable plugin on the market to address this, given how smoothly Style Variations operate within the Site Editor (“Browse Styles” pane) and the growing client expectations on Dark Mode.
Considerations
lightanddarkVariations forprefers-color-schemeRelated conversations:
#42828
#24368
https://wordpress.org/support/topic/best-practice-theme-json-for-dark-mode/
egor-kugno commentedon Apr 18, 2024
Good afternoon
Please allow theme authors to publish their themes with theme switching blocks from dark to light (and vice versa) in the Wordpress repository.
This problem has been pointed out by one of the most popular authors of free themes for vordpress, Anders Noren
in this topic
I am sincerely convinced that Anders's opinion is worth listening to - he personally with his free themes has added to the worldwide popularity of Wordpress at least 1 percent of those 43% of the world's sites that run on Wordpress.
bph commentedon Jul 13, 2024
@richtabor built such a block: See Dark Mode Toggle Block
richtabor commentedon Jul 17, 2024
I don't think this block would be suitable for core, as we'd need a way to effectively apply a dark mode style to any theme (not feasible).
My dark mode toggle block is is block, along with instructions for setting up CSS on your end.
I propose we close this.
dhanson-wp commentedon Aug 1, 2024
I recently came upon this variation style switcher block in this video. Looks like a pretty simple plugin that accomplishes the main feature in this suggested feature for block themes.
saschafoerster commentedon Aug 3, 2024
@dhanson-wp Tried the last plugin out with my custom styles and it did not work as expected. Also it creates an annoying menu in the backend instead of hiding.
justintadlock commentedon Aug 9, 2024
I believe it should support any number and not be limited to something like dark vs. light mode.
I think the best course of action would be to integrate with the existing style variations system so that we're not introducing a new concept for themers to learn.
Under the hood, there's probably some things to work out with the way variations are stored. For example, users can't make per-variation style overrides, and style variations themselves are stored as user customizations (see: #62661).
daotw commentedon Sep 11, 2024
Reminder:
It should automatically detect site visitors' preference through an OS setting or a user agent setting, or provide a way to work with
prefers-color-scheme.TheJeffr0 commentedon Jan 31, 2025
Throwing in my two cents, I'd love to see this become a core feature.
Superkikim commentedon May 2, 2025
Definitely something we need on Wordpress
TheJeffr0 commentedon Sep 2, 2025
At first, I wanted this to become a core feature. However, after reading and discussing Rich Tabor's point above (#48249 (comment)), it's clear that this task is nearly impossible and needs to be handled on a per-site basis with a custom solution.
Superkikim commentedon Sep 4, 2025
Not sure I understand why it can't be done. At least a theme switcher on UI.
Let's say I have Twenty-four child theme with light colors and a I make a second child theme with dark colors. If I add a button for users to click and it just switch themes, how difficult can that be?
I get that it light not be suitable if you use it with completely different theme architecture but that seems like an acceptable limitation to me.
justintadlock commentedon Sep 4, 2025
Right now, the most ideal way I can think to do it would be to move toward a modern solution using the native CSS
light-dark()function. But this would require an overhaul of how colors are handled in Global Styles, providing a mechanism for users to customize the colors for both light and dark mode. That's pretty much a prerequisite before even discussing a toggle block. Such a method assumes that the theme isn't already built with a custom design token system that goes beyond the current limitations ofsettings.color.palette.Building it this way assumes we're building with the awareness that such features as
schemed-value()could be a thing in the future and thatlight-dark()is just a stepping stone: w3c/csswg-drafts#9660In the meantime, this is really something that theme authors can be implementing themselves in various ways. I'm pushing to get an article up on the Developer Blog in the next week that explains one method of doing it with modern CSS features.
But there are so many ways to tackle the same problem that I don't see a 100% clear path for Core. This is where exploration from theme authors is so crucial. Instead of just saying that we want something, we need to be sharing how we solved it and the feedback from real-world users on how it works.
dhanson-wp commentedon Sep 5, 2025
This plugin is how the Special Projects team handles light/dark toggle. https://github.com/a8cteam51/special-projects-blocks-monorepo/releases/tag/light-dark-toggle%400.2.1
Superkikim commentedon Sep 5, 2025
Check out this project.
https://github.com/mosne/mosne-dark-palette
I tried this one. But I had lots of difficulties to implement. That said, I'm developing my own theme and I suck at it. Could be might fault. But I got it work occasionally.
justintadlock commentedon Sep 11, 2025
I published a tutorial on building this on the WordPress.org Developer Blog: https://developer.wordpress.org/news/2025/09/building-a-light-dark-toggle-with-the-interactivity-api/
nahuai commentedon Sep 16, 2025
Amazing tutorial Justin.
As a theme creator, I'd use a very similar approach. I'm also inclined to use modern CSS so I'd love to be able to use
light-dark()function paired with an interactive native block.But for that strategy to be user friendly on the site editor, WordPress core would need to provide a mechanism for users to customize both light and dark mode colors, as Justin pointed out.
I'd love to see this implemented, I can't think of a better approach for this purpose.
justintadlock commentedon Sep 16, 2025
For my own theme, I'm using a similar setup to the tutorial, but exploring handling colors differently. Rough example of this:
{ "settings": { "color": { "palette": [ { "name": "Primary - 500", "slug": "primary-500", "color": "#555555" } ] }, "custom": { "color": { "text": { "example": "light-dark(var(--wp--preset--color--primary-100), var(--wp--preset--color--primary-900))" } "background": { "example": "light-dark(var(--wp--preset--color--primary-900), var(--wp--preset--color--primary-100))" } } } }, "styles": { "color": { "text": "var(--wp--custom--color--text--example)", "background": "var(--wp--custom--color--background--example)" } } }This is a basic design token system. And it would allow users to customize the palette. However, it doesn't allow them to assign the light/dark colors to blocks. But it's another approach to colors themselves.
It's probably outside the scope of this specific ticket, but I'd love to see WordPress support a layered design token system (primitive -> semantic -> component). Otherwise, we end up with wildly different approaches to things like light/dark toggles, fixing one issue at the expense of another.
bhubbard commentedon Oct 12, 2025
I think we need to make a distinction between toggling different themes VS theme styles VS a dark mode/light mode toggle.
For dark mode / light mode I see it as a dropdown with system (default), dark, and light. Ultimately this would somewhere toggle class names in the body tag most likely and set prefers-color-scheme: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
hazencruz commentedon Aug 20, 2026
It's really painful staring at a lightbulb while I edit my site's posts. Updooting this.