What I heard here, if I can't see the UI, what I'm hearing is button, button, button, button. Very long input. Button, button. And then you go back to the first button.
There was no mention of a tab here. Like, which one of these are tabs? And it's because screen readers cannot really look at your visual implementation, visual design, and infer things like these are tabs.
And so, if you don't provide that information, a screen reader wouldn't really get to know that they can switch the first three buttons, they can switch between them. And so, how do we... We probably did something wrong here, right? Because the button element, maybe we didn't use the right element. Maybe we should use the tabs element. But of course, there is no tabs element. That doesn't exist on the web, at least yet. So, we still just have these divs and buttons.
And this is where the ARIA spec comes in. ARIA stands for Accessible Rich Internet Application. It's a spec. It's an interesting read. And something that the ARIA spec has are roles. So, ARIA provides us with a list. It's a fixed list of roles that conveys the semantics of structure. So, for example, layout, the appearance, how the content is structured, like headings, lists, tables, tabs. These are provided by roles. And one of the roles is tab list. So, this is what we need here.
How you can use these roles is we go back to the div and we add a role tab list. And to each button here, we are going to add a role tab.
So, we've done something interesting. A button by default has a role button. But when you add a role tab to it, it actually overrides the semantics and no longer considers it a button. We could, in fact, remove the button element and just use a div and it would convey the same exact semantics.
Comments