DEV Community

Discussion on: An Accessible Dark Mode Toggle in React

 
grahamthedev profile image
GrahamTheDev • Edited

I think React's onClick is the equivalent of writing an event handler like click. I think it's that works on Enter and Space and click automatically.

Yeah sorry I made a complete hash of that...trying to explain what I was thinking would be more confusing than me just saying "it is fine as it is, ignore me" so I will just say that! ๐Ÿคฃ

And as for the points I raised, you are right, they are not important now, just add them to the list!

I think the last thing I should perhaps have clarified earlier on to save us both a lot of too and fro is that the current design is accessible to a stage where it is better than 95%+ of dark mode toggle switches out there! It certainly is good enough, it is production ready, it would pass an audit(see "NECESSARY CAVEAT") and in fact it is more than good enough it is great!

The changes I suggested will not affect WCAG in any way or affect an audit either, they are good practices not compliance points. (WCAG is far from all encompassing).

I think a label on focus/hover should be sufficient for the extraneous color mode toggle that's not a form and am willing to accept if that makes it just a tad bit less accessible for my pretty design. ๐Ÿ˜ญ

It certainly is, there is knowing the ideal and working to constraints, it is a fair compromise (I am not militant even if it seemed like it, knowing when you can "cut a corner" and still be accessible is part of the game and what makes accessibility fun!)

NECESSARY CAVEAT - Really prickly auditors might say the lightmode version of the toggle does not have contrast of 3:1 with it's surroundings under SC 1.4.1 Non Text Contrast...if they did say that in a report and given the control design using multiple colours etc. I would call them a **** ****** for being picky, but I can't say it would defo pass without pointing that out!

Thread Thread
 
abbeyperini profile image
Abbey Perini

Ooooh I will check out the color contrast because I am militant about that. ๐Ÿ˜‚ I'm not sure any of the automatic tools caught it, but I'll have to doublecheck.

Thread Thread
 
grahamthedev profile image
GrahamTheDev

I don't think automated tools would catch it as you are styling the label rather than the control, the tools are pretty dumb when you start using fancy tricks!