How to Build a Light/Dark Toggle Button for Themes #378
Closed
justintadlock
started this conversation in
Topic Ideas
Replies: 2 comments
-
This proposal was approved and has now been moved to a ticket: #379 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Published here: https://developer.wordpress.org/news/2025/09/building-a-light-dark-toggle-with-the-interactivity-api/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In December, I published a tutorial on mastering light/dark styles in block themes using only
theme.json
(ticket: #336). Since then, Gutenberg has opened a new<button>
option for the Button block (previously only a link). Coupled with the Interactivity API and a filter on block render, it's now possible to create interactive buttons without building a custom block.The plan for this tutorial is to write a followup that builds upon the original tutorial, showcasing how to build the toggle button to switch between light and dark mode and persisting it across page views. Quick demo of a working prototype:
light-dark-toggle.mp4
Beta Was this translation helpful? Give feedback.
All reactions