Dark mode toggle design #1
Comments
Thank you for creating the issue @hedgefield and for carrying the discussion over! 👍 I too think that putting it on the top would be better. The reason I chose to put it on the bottom now is because until we make a decission, the bottom is safer and doesn't interfere with the overall design of the site. On the top we've got the header, the mobile-menu toggle etc, so it's just easier to put it in a dead-zone like the bottom-right.
Yeah, that one is a solution that can work everywhere. We can inject a sub-footer (for lack of a better word) with that toggle. It would definitely be the most accessible and "safe" option.
The only reason I don't particularly like the single-icon approach is because it's not clear that it's actionable. However, if we add a label as per your suggestion then it would definitely be a solid option (and pretty too 😉)
For context, in a slack discussion, it was suggested that the toggle can be injected in the actual menu of the site, as the last item (see https://livecodestream.dev/post/2020-08-06-a-better-approach-to-dark-mode-on-your-website/ for an example). |
Thanks for creating this issue. I'd like to remind everyone that the "Switch toggle" controls have been discussed at length in the context of the Gutenberg project because they bring in some inherent accessibility issues that need to be addressed. Even if these toggles are technically implemented with a native checkbox and a properly associated In a theme that aims to be WCAG "AAA ready" it's probably worth considering to use another control rather than a switch toggle. I'd like to stress that the AAA level requires the most advanced level of accessibility thus any interactive control needs to be understandable and operable by all users. A bit ironically, the current toggle (same for the Gutenberg toggle) is more accessible for blind screen reader users than for sighted users. For blind screen reader users: This works perfectly for blind users. Aside: the verb "Toggle" should be avoided because it's difficult to translate. See WordPress/twentytwentyone#526 and https://core.trac.wordpress.org/ticket/34753 For sighted users: This is how the toggle looks when styled: Visually, the main problems are:
Visible label:
Indication of the state:
I'm not suggesting to use the same solution but a some text to visually represent the state is necessary. Worth noting the Twenty Twenty-One toggle implementation come from this one: https://codepen.io/waynedunkley/pen/YybgGo which does use some text to represent the state (see "AM" and "PM"). Also the third example linked bt @hedgefield has visible text to clarify the state (though it's not fully accessible for other reasons): https://codepen.io/sheelah/pen/dEmyqx Overall, to declare this toggle "AAA ready" I'd strongly recommend to add some textual representation/better indication of the state. |
Regarding the toggle placement:
I'd totally agree placing the toggle in the top part of the page would make sense. However, placing it within a |
Thanks for the important context @afercia! I like that codepen you linked also - though I had it bookmarked because it's one of the few that does it with CSS only ha. But it does give a nice example for the label. Putting "Dark" and "Light" on the side of the control could make it pretty lightweight. So just "Toggle dark mode" as label is not enough for AAA if I understand you correctly? It has to have both states spelled out? I'm thinking of three different combinations we could try:
|
One more alternative: a toggle button (that is a button with a pressed state). See https://inclusive-components.design/a-theme-switcher/ It's a very long article and the implementation is made with React but it can be done with vanilla JavaScript. Example of the two states visual: Re: the labeling (the button text): it's good that there's a "fixed part" to communicate what the button is about and a dynamic part that communicate the state with text, besides the inversion of colors. |
Ooh I like that one a lot too! Better than any regular toggle, maybe not as nice as a dynamic icon + label, but certainly something that fits in the theme's aesthetic. |
Agreed. I already started working on it today on #2, I'm hoping I'll have it ready by tomorrow 🎉 |
The button implementation was done in #2 and merged. It now gets injected after the logo/sitename and before the main nav, so it's properly positioned in the tabbing-order. The fixed-bottom implementation wasn't trashed, it's still an option by changing this line from twentytwentyone-dark-mode/functions.php Line 214 in b8c4153
|
I like that, nice work! I wonder if it might fit in slightly better if the default and hover states were reversed, but also, that risks the ghoOost button problem. This is great :) |
Looking through a bunch of articles and documentation for OS', it looks like "Dark Mode" is the standard terminology — can we update it to:
|
Makes sense. |
Super minor, could you add a space between |
Done in ab1b64f 👍 |
Thanks! |
Closing this one since I think all items reported were already fixed. For any new issues please create new tickets. Easier to track and fix if they are separate 👍 |
Just to carry this one over from WordPress/twentytwentyone#622 (comment), I'd like to explore what the nicest toggle design would be. To reiterate: it has to be minimal to match the TT1 style, and fully accessible. I also feel like the sun/moon analogy is an accepted pattern for this feature by now so that it could be understood without labels, but any extra affordances that are possible are always good.
@aristath showed a few examples, and I quite like these:
https://codepen.io/lucas-labs/pen/wvBvEZq
Very clearly shows that clicking on this thing will move from one state to the other. In our case, I'd switch the icons, not rotate the arrow, so that the LTR/RTL reading direction is always consistent.
https://codepen.io/sandeshsapkota/pen/xxVmMpe
I like the iconography and simplicity of this one. I maybe wouldn't make the animation so outspoken, and this one could really benefit from a subtle label below it. For a11y though, the label shouldn't change content, so then it gets a little trickier. What do you call it? It's not a theme. Not exactly a color scheme. Maybe just "Toggle dark mode"? As we can consider the light mode as the 'default' mode, dark mode is the special sauce.
https://codepen.io/sheelah/pen/dEmyqx
This feels like a solid basic option too. It's very clear, simple control state. It's not as sexy but it sure works.
I think my preference would go to the second one with a label. What do you think @melchoyce?
Regardless of the exact design, I've heard several people mention it should probably be at the top of the page, and I agree. Something that touches the meta of a site, like nav, language, currency, or dark mode, feels like it should be at the top. Maybe indeed as part of the menu as @aristath suggested?
The text was updated successfully, but these errors were encountered: