So, starting with accessibility, which is something that we are finally talking a lot about these days. I don't know about you, but I've always had this kind of reaction that we always think, we are, we tend to think that we are addressing accessibility enough. But then suddenly we start getting, I don't know, some tickets or some open issues like, oh hey, this component is not working properly with the zoom, or this doesn't have the proper contrast, or I don't know, the screen reader is having trouble reading that. So, accessibility is complicated for us to implement.
That's the point. And one example is, let's think a little bit for a while about press interactions. So, press interactions can happen on different scenarios. They can happen on mouse clicks, they can also happen on touch taps, they can happen when we press some keys like enter or space keys, and they can happen even on virtual clicks performed by some screen readers. And if we want to properly address them on our own, we have to do a lot of things. So, first we have to use pointer events when they are available, and then fall back to mouse and touch events. We also have to think about text selection, so we have to disable it in some scenarios, especially on mobile when we are pressing things. Not only that, but we have to handle cancelling them sometimes, for example on scroll events. And in the end we see ourselves having to normalize a lot of cross-browser inconsistencies that still exist nowadays, and so on, and so on. Not to mention area.
So, if you've done some accessibility work, you're probably familiar with area. But the thing about Weight Area is that it provides semantics, mostly. So it's like a contract that you should follow. But usually the implementations that we have in the browsers, in the whole web platform, they either lack some feature, or probably you cannot customize them enough, or sometimes it doesn't even exist, so it's up to you as a developer. And that's an incredibly difficult task. So, one of the first lessons we learned was not spend a lot of time, for example, discussing how to implement one or another focus traps, or going through keyboard navigation, or researching the appropriate area thing for something. Instead, finding an existing, and we have a lot of them, library that brings accessibility, mostly, out of the box, and that can be customized enough to match our tokens, our brand, etc. And those libraries, they usually come in three different flavors, or three different layers of abstraction.
So, you have composition primitives, like React Area and Downshift, and as the name suggests, you just build them together, but they don't offer any styling, or anything at all. Sometimes it comes, like React Hooks that you can plug into your components. Then, you have, one level above, there are the unstyled components, those are also known, nowadays, as headless components, so, it's really cool, and you've probably heard about them everywhere. So, we have Redix, ReachUI, HeadlessUI, and Reakit. And then, we have the fully-styled components, so, those usually come with very, very powerful framing systems, and we have a set of components, they are opinionated, but we just customize them to match our design tokens, our brands, etc., via their powerful framing systems. So, the thing is, you should ask, like, which one should I follow, which layer of abstraction or which library amongst these those. It really depends on the context, of course, of your product, your company, etc., but what you should keep in mind is go with one that has accessibility as a core focus and that is also themeable and customized enough to match your stuff. From my experience, I've usually went with composition primitives when, let's say, we have some huge design system implementation running and it's in production and etc., and we're getting a lot of issues with accessibility, we have a lot of code that does styling and that kind of stuff.
Comments