-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Block: Dark Mode Toggle #42828
Comments
This could be useful, but might also be tricky to deliver in the plugin because it would be very difficult to guarantee that it would work for all themes. How would you see it working, especially in terms of styles? |
@ramonjd I could see the default being the toggle, if there are multiple styles available then I could see a possible setting to allow it to be a dropdown that lets the user choose the style. |
I think we'd need to add some tools for themes to be able to define "light" and "dark" colors. |
@scruffian I agree, maybe this needs to be supported in theme.json for styles? |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
Any suggestions on how to move this forward? |
Isn't this already possible with global style variations? See: https://fullsiteediting.com/lessons/global-style-variations/ Given that light/dark modes will be very theme-specific, it makes sense that a theme could have 2 x global style variations to cater. |
A theme can have many styles. The original request is to have a dark mode/light mode toggle button block, such as this one for example: https://www.w3schools.com/howto/howto_js_toggle_dark_mode.asp This light mode/dark mode toggle is becoming more common across websites today. As a website visitor if my browser/os is set to dark mode, they may still wish to see the website in light mode. At the moment I don't think theme.json has a way to set a "style" as dark mode or light mode specific, nor does it support "prefer-color-scheme". Further Reading: |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
Just a note that mainstream browsers have JS and CSS support for detecting the user preference on dark-mode. It's nothing but sparkling laziness to use a physical toggle if the default is not to respect the standards-based API's. I'm also not 100% sold that it matters if the editing experience needs to be in lock-step with the display presentation theme. There is a preview button if someone needs to see what content looks like on their frontend as a visitor would see it. I Created Automattic/blocks-everywhere#27 for Gutenberg outside of WordPress. Which presently describes a hack, which "works for me". This hack is predicated on the visual editor not being a WYSIWYG website editor; which honestly neither TinyMCE or Gutenberg are capable of achieving despite a lot of sunk effort and painful engineering to that end. |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
Not sure who this bot is helping, but the progress on the linked issue I believe is that it was closed (marked as completed despite not being completed) |
This issue for example does not need any more information. The only labels applied that make sense are I'd argue that from labels, the following seemed like they might apply |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
Maybe we can move this forward by adding support for "prefers-color-scheme" to the styles JSON? prefers-color-scheme: dark |
Thanks @bhubbard So one limitation of a solely CSS based approach (although that is better than what we have now); is that it does not let a user set an override (for session or otherwise). I did use the prefers-color-scheme, by-proxy, but because the software I'd integrated Gutenberg with had system theme independence, I also used some JS Automattic/blocks-everywhere#27 I Think not locking down to solely CSS is an ideal world, and I'm open to any world where I'm not writing custom CSS hacks 👍 |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
I'd like to move that bot forward... into the bin. While I understand the need to keep issues fresh and assess interest, it comes across as disinterest.
For me it was purely aesthetic, but there are always benefits to supporting multi-palette UI if the cost can be controlled. |
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks. |
@richtabor made a block for this: https://rich.blog/dark-mode-toggle-block/ |
So is this asking for a block for websites to add a toggle, or for Gutenberg itself to support dark-mode? All my posts were for the latter, not the former. |
@Lewiscowles1986 So the original request is for a new toggle block. Browsing a lot of templates, I do see a lot of sites doing a drop-down that has light, dark, and system (default) as the options. And I feel this is probably best, as it defaults to system, but site visitors can then choose to see light and dark when they wish. Based on the comments, I do see some work that may need to be completed first, such as let developers define "prefers-color-scheme" for color palette's set within the theme.json file. It might also make sense to have this as a site option stored in the wp_options table, with default being system, but allowing site owners to override the default for the site globally. |
@bhubbard are wp_options user-specific? To add complexity, I'm not 100% certain, that a user wanting dark-mode, would wish to do so for all of their devices. |
@Lewiscowles1986 wp_options is not user-specific. But I was thinking its more for site owners to choose the default for their site, if they choose to not have it be "system". The idea being a user can always use this toggle or drop-down to then change on the front-end of the site. |
What problem does this address?
A simple block to let site visitors toggle between dark mode and light mode.
The text was updated successfully, but these errors were encountered: