What I learned by creating a dark mode toggle https://clagnut.com/blog/2437 #css #design #typography
=> More informations about this toot | More toots from Richr@mastodon.social
@Richr wow, great write up. Will add it to my list of best ways to do this task.
=> More informations about this toot | More toots from Luke@typo.social
@Luke thanks Luke. file it under possible ways to achieve this task. I doubt it's the best, but I certainly learned a surprising amount. Including that reduction in font weight of 15%, which was a lot more than I expected.
=> More informations about this toot | More toots from Richr@mastodon.social
@Richr Always givin' back, arn'tcha, buddy? Respect.
=> More informations about this toot | More toots from Luke@typo.social
@Richr Great article! I recently added a light/dark mode toggle to my website using a checkbox and CSS icons, but I might revisit it after reading this.
=> More informations about this toot | More toots from codemacabre@social.coop
@Richr
When I try VoiceOver for Mac (14.7.1, Safari 18.2) with implicit , the SVG's provides the radio button's name, no problem. However, there are known problems with implicit labelling and voice control software so it's best to always use explicit labelling (for
, id
).
However in VoiceOver for iOS (18.2.1), the radio buttons are unnamed. This may be considered an iOS bug but it's solved by adding role="img"
to each .
Alternately, use aria-labelledby
to point to ids on the elements as an effective workaround (I'd still leave the explicit labelling in place, again for voice control). An advantage to this is you can then add aria-hidden="true"
to each so they're not in the reading order, only the radio buttons are.
https://codepen.io/ccwilcox/pen/WbeKJBg?editors=1000
I would make focus styling for the SVGs more apparent so there's a clear difference between when they're selected (one always is) and when they're focused and selected.
=> More informations about this toot | More toots from cwilcox808@c.im
@Richr
A downside to using radio buttons instead of s is when navigating by keyboard, focusing a radio also activates it (I consider this a mistake from when HTML forms were originally made but now we're stuck with it).
Keyboard navigating from System to Dark requires temporarily activating the Light theme. I'd consider enabling Light mode when one wants Dark more jarring than the reverse so changing the radio order to System, Dark, Light could help.
=> More informations about this toot | More toots from cwilcox808@c.im
@cwilcox808 thanks Curtis. I’ll give all that a try.
=> More informations about this toot | More toots from Richr@mastodon.social
@cwilcox808 @Richr Is there an advantage to delegate the titling of an interactive element (here, the radio button) to a inside the , as opposed to putting the title in an aria-label
on the radio buttons directly?
=> More informations about this toot | More toots from pixelambacht@typo.social
@Richr I was looking for ways to do this recently, none of which was concerned with accessibility. Thanks a lot for explaining the whole process, and for sharing!
=> More informations about this toot | More toots from azraph@fosstodon.org This content has been proxied by September (ba2dc).Proxy Information
text/gemini