Skip to content

Core Block suggestion: Theme Style Toggle #48249

Open

Description

What problem does this address?

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.

Can be as easy as this example.

Activity

  1. added
    Needs Accessibility Feedback
    New Block
    on Feb 20, 2023
  2. added
    [Type] Enhancement
    on Jul 27, 2023
  3. joedolson commented on Aug 4, 2023

    @joedolson
    Contributor

    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:

    1. Should this only support two design variants, or more?
    2. Should there be a mechanism in the style book for quickly comparing the variants to ensure that the design implementation is complete on both?
  4. removed
    Needs Accessibility Feedback
    on Aug 11, 2023
  5. spacedragn commented on Nov 28, 2023

    @spacedragn

    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

    Related conversations:
    #42828
    #24368
    https://wordpress.org/support/topic/best-practice-theme-json-for-dark-mode/

  6. egor-kugno commented on Apr 18, 2024

    @egor-kugno

    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.

  7. bph commented on Jul 13, 2024

    @bph
    Contributor

    @richtabor built such a block: See Dark Mode Toggle Block

  8. richtabor commented on Jul 17, 2024

    @richtabor
    Member

    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.

  9. dhanson-wp commented on Aug 1, 2024

    @dhanson-wp

    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.

  10. saschafoerster commented on Aug 3, 2024

    @saschafoerster

    @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.

  11. justintadlock commented on Aug 9, 2024

    @justintadlock
    Contributor

    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).

  12. daotw commented on Sep 11, 2024

    @daotw

    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.

  13. TheJeffr0 commented on Jan 31, 2025

    @TheJeffr0

    Throwing in my two cents, I'd love to see this become a core feature.

  14. Superkikim commented on May 2, 2025

    @Superkikim

    Definitely something we need on Wordpress

  15. TheJeffr0 commented on Sep 2, 2025

    @TheJeffr0

    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.

  16. Superkikim commented on Sep 4, 2025

    @Superkikim

    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.

  17. justintadlock commented on Sep 4, 2025

    @justintadlock
    Contributor

    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.

  18. dhanson-wp commented on Sep 5, 2025

    @dhanson-wp

    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

  19. Superkikim commented on Sep 5, 2025

    @Superkikim

    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.

  20. justintadlock commented on Sep 11, 2025

    @justintadlock
    Contributor

    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/

  21. nahuai commented on Sep 16, 2025

    @nahuai

    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.

  22. justintadlock commented on Sep 16, 2025

    @justintadlock
    Contributor

    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.

  23. bhubbard commented on Oct 12, 2025

    @bhubbard

    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

  24. hazencruz commented on Aug 20, 2026

    @hazencruz

    It's really painful staring at a lightbulb while I edit my site's posts. Updooting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    New Block[Type] Enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions