Case Study: Building Accessible Reusable React Components at GitHub

Rate this content
Bookmark

Twitter influencers would have you believe that if you just use the semantic html tag for elements instead of a div, your components will be accessible. but there’s a lot more that goes into it!

Let’s zoom in on one component from GitHub (one that you’ve probably used before!) and look at all the accessibility considerations involved and interesting challenges in implementing them.

This talk has been presented at React Summit 2024, check out the latest edition of this React Conference.

FAQ

The speaker is Sid, whose full name is Siddharth. He prefers to go by Sid to avoid mispronunciations of his name.

Sid works on the design systems team at GitHub, where he maintains the React component library.

The main focus of Sid's talk is on building accessible React components, with an emphasis on accessibility.

No, Sid is not an accessibility expert. He refers to himself as a 'silly React guy' who has learned about accessibility from working with experts over the past year.

Sid emphasizes using the correct HTML elements, like using a button instead of a div for interactive actions, to improve accessibility. However, he acknowledges that this is just one part of making web experiences accessible.

ARIA (Accessible Rich Internet Applications) provides a set of roles that convey the accessibility semantics of structures on a web page. It helps in making web content and applications more accessible to people with disabilities.

Sid identified that using buttons for tabs can be problematic for screen reader users because it doesn't convey hierarchical or contextual information well. Instead, he suggests using ARIA roles like 'tablist' and 'tab' to provide better accessibility semantics.

'ARIA disabled' is an attribute that keeps an element in the tab order and allows it to be focusable, unlike the 'disabled' attribute which removes elements from the tab order. 'ARIA disabled' is preferred to make the element accessible while indicating that it is not currently interactive.

Sid recommends the Axe family of tools, which includes plugins for various environments like CLI, Jest, and Storybook. These tools help catch accessibility issues, but he emphasizes that manual testing is also necessary.

Sid suggests providing clear information about the state and conditions of UI elements, such as using 'ARIA disabled' and 'ARIA described by' to make elements accessible while explaining why they are disabled. This approach improves the user experience for both sighted and screen reader users.

Siddharth Kshetrapal
Siddharth Kshetrapal
29 min
14 Jun, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The talk discusses building accessible React components and emphasizes the importance of using the correct HTML elements and ARIA roles for accessibility. It explains how to navigate and select options within a form and how to add supplementary text using Aria described by. The speaker also discusses the benefits of using conditional checkboxes and ARIA disabled to improve the UI. Additionally, the talk explores the role of JavaScript in web accessibility and provides recommendations for testing website accessibility.

1. Introduction and Background

Short description:

I'm Sid, a front-end developer on the design systems team at GitHub. Today, I want to talk about building accessible React components.

Thank you for the introduction. I'm Sid. My full name is Siddharth but I don't like people butchering my name. I just go by Sid. It's fine. It's easier. I work on the design systems team at GitHub and I spend a lot of time maintaining the React component library that's part of the design system. I want to talk about building accessible React components with a focus on the accessible. A lot of the things I talk about today are actually framework-agnostic. But a fair warning, I'm not an accessibility expert. I'm just a silly React guy. But I did spend a lot of time in the past year working with accessibility experts and I've absorbed a lot of things and maybe as a front-end developer, if you're a front-end developer like me, this kind of an introduction is more helpful than a very accessibility-focused one.

2. Making Accessible Experiences

Short description:

To make accessible experiences, using the correct HTML element is important. However, there's more to it. Tabs are a good pattern for showing controls in a small space. The implementation involves buttons and changing states. When using a screen reader, the focus on a button is announced, along with its label and associated actions.

All right. Fingers crossed. Let's go. So, things... What are the things that we need to make accessible experiences? If you listen to influencers on Twitter, you should use a button and not use a div. And it's usually accompanied by a code sample with a nice purple background. And so you have to use the correct HTML element. And if you listen to them, that's kind of it. We could just go and have lunch now. But of course that's... This framing is very reductive because there's so much more that goes into it. This is not false. You should still try to use the right element. And if it's an interactive action, then you should use a button. But there's so much more that goes into it, for example.

So there is this interface, there's this popup widget on GitHub where a lot of information is densely packed. So you have code spaces, copilot, and the local tab. And when you have to show a lot of controls in a very tiny space, tabs is a really good pattern and that's what we use here. And it really... I think it works really well if you're using the UI this way. And the implementation is also kind of funky. We have buttons. We do use buttons. And I'm setting a state here of what is the selected tab. Can you see my cursor? Nice. And then we all kind of just agree that when it's a hill like this, that's a tab. And when you change the tab, the hill moves. I don't know why, but we all kind of know this, and this is a design common pattern. So that's what I do. I give a class name. And that's what the class name makes a hill. But what if somebody who cannot see the screen and instead is using a screen reader, what do they hear? What do they perceive? Let's try it out. Also, this is gonna be a test of the audio. So we'll find out. If it's too loud, it will get fixed. Don't worry.

Okay. Let's go. VoiceOver on application. React app. Perfect. So any time you start VoiceOver on Mac, it starts by announcing that VoiceOver has been enabled and it's on the React app. Next. Code. Menu popup button has keyboard focus. So it will announce what element has keyboard focus right now. So if you can't see anything and if you're only hearing this, you know that the focus is on a button. It has a label code. And it has a menu popup. So because you know it has a menu popup, you can press enter and you can open the menu popup.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
React Summit 2022React Summit 2022
17 min
Composition vs Configuration: How to Build Flexible, Resilient and Future-proof Components
Top Content
Today's Talk discusses building flexible, resilient, and future-proof React components using composition and configuration approaches. The composition approach allows for flexibility without excessive conditional logic by using multiple components and passing props. The context API can be used for variant styling, allowing for appropriate styling and class specification. Adding variants and icons is made easy by consuming the variant context. The composition and configuration approaches can be combined for the best of both worlds.
The Worlds Most Expensive React Component and How to Stop Writing It
React Advanced Conference 2021React Advanced Conference 2021
23 min
The Worlds Most Expensive React Component and How to Stop Writing It
Top Content
Today's Talk discusses expensive React components and API design, with a focus on the cost of coordination and overcoming imposter syndrome. The speaker shares a story about a cat trying to fix salted coffee, highlighting the importance of finding simple solutions. The billion dollar component on ReactJS.org is examined as an example of an expensive component. Techniques for customizing messages, improving accessibility, and using polymorphic props are discussed. The Talk concludes by emphasizing the cost of communication and the need to evaluate if props and components are the right tools for the job.
Find Out If Your Design System Is Better Than Nothing
React Summit 2022React Summit 2022
20 min
Find Out If Your Design System Is Better Than Nothing
Building a design system without adoption is a waste of time. Grafana UI's adoption is growing consistently over time. The factors affecting design system adoption include the source mix changing, displacement of Homebrew components by Grafana UI, and the limitations of Grafana UI's current state. Measuring adoption is important to determine the success of a design system. The analysis of code through static code analysis tools is valuable in detecting and tracking component usage.
How to achieve layout composition in React
React Summit 2022React Summit 2022
8 min
How to achieve layout composition in React
This talk discusses achieving layout composition in React using Bedrock Layout Primitives. By componentizing CSS layout, complex layouts can be achieved and reused across different components. The talk also covers the challenges of achieving complex layouts, such as card lineups, and provides solutions for maintaining alignment and responsiveness. The BedrockLayout primitive library simplifies web layouts and offers flexibility in composing layouts.
CCTDD: Cypress Component Test Driven Design
TestJS Summit 2022TestJS Summit 2022
25 min
CCTDD: Cypress Component Test Driven Design
Cypress component test-driven design can take front-end engineers to the next level by covering TDD examples, component testing, endpoint testing, and recommended best practices. The TDD flow involves starting with failing tests, making them work, and then improving them. Component tests can be written incrementally, using custom wrappers and props. The differences between React Testing Library and Cypress Component Test lie in the API style. Code coverage can be achieved with Cypress component tests, and the Pack.js Cypress Adapter can be used to avoid test duplication between the backend and frontend.
Generic Components with TS and React
React Day Berlin 2022React Day Berlin 2022
10 min
Generic Components with TS and React
Ilya, a Staff Engineer in ArtSecurity, gives a talk on using generic components with React and TypeScript. He demonstrates how to pass generics to React components and addresses syntax limitations. Generics allow components to operate on data without a defined shape and are commonly used in form field components and component libraries.

Workshops on related topic

Hands-on with AG Grid's React Data Grid
React Summit 2022React Summit 2022
147 min
Hands-on with AG Grid's React Data Grid
WorkshopFree
Sean Landsman
Sean Landsman
Get started with AG Grid React Data Grid with a hands-on tutorial from the core team that will take you through the steps of creating your first grid, including how to configure the grid with simple properties and custom components. AG Grid community edition is completely free to use in commercial applications, so you'll learn a powerful tool that you can immediately add to your projects. You'll also discover how to load data into the grid and different ways to add custom rendering to the grid. By the end of the workshop, you will have created an AG Grid React Data Grid and customized with functional React components.- Getting started and installing AG Grid- Configuring sorting, filtering, pagination- Loading data into the grid- The grid API- Using hooks and functional components with AG Grid- Capabilities of the free community edition of AG Grid- Customizing the grid with React Components
Practice TypeScript Techniques Building React Server Components App
TypeScript Congress 2023TypeScript Congress 2023
131 min
Practice TypeScript Techniques Building React Server Components App
Workshop
Maurice de Beijer
Maurice de Beijer
In this hands-on workshop, Maurice will personally guide you through a series of exercises designed to empower you with a deep understanding of React Server Components and the power of TypeScript. Discover how to optimize your applications, improve performance, and unlock new possibilities.
 
During the workshop, you will:
- Maximize code maintainability and scalability with advanced TypeScript practices
- Unleash the performance benefits of React Server Components, surpassing traditional approaches
- Turbocharge your TypeScript with the power of Mapped Types
- Make your TypeScript types more secure with Opaque Types
- Explore the power of Template Literal Types when using Mapped Types
 
Maurice will virtually be by your side, offering comprehensive guidance and answering your questions as you navigate each exercise. By the end of the workshop, you'll have mastered React Server Components, armed with a newfound arsenal of TypeScript knowledge to supercharge your React applications.
 
Don't miss this opportunity to elevate your React expertise to new heights. Join our workshop and unlock the potential of React Server Components with TypeScript. Your apps will thank you.
From Idea to Production: React Development with a Visual Twist
React Summit 2023React Summit 2023
31 min
From Idea to Production: React Development with a Visual Twist
WorkshopFree
Omer Kenet
Omer Kenet
Join us for a 3-hour workshop that dives into the world of creative React development using Codux. Participants will explore how a visually-driven approach can unlock creativity, streamline workflows, and enhance their development velocity. Dive into the features that make Codux a game-changer for React developers. The session will include hands-on exercises that demonstrate the power of real-time rendering, visual code manipulation, and component isolation all in your source code.
Table of the contents: - Download & Setup: Getting Codux Ready for the Workshop- Project Picker: Cloning and Installing a Demo Project- Introduction to Codux Core Concepts and Its UI- Exercise 1: Finding our Feet- Break- Exercise 2: Making Changes While Staying Effective- Exercise 3: Reusability and Edge Case Validation- Summary, Wrap-Up, and Q&A
Crash Course into TypeScript for content from headless CMS
React Summit 2022React Summit 2022
98 min
Crash Course into TypeScript for content from headless CMS
WorkshopFree
Ondrej Polesny
Ondrej Polesny
In this workshop, I’ll first show you how to create a new project in a headless CMS, fill it with data, and use the content in your project. Then, we’ll spend the rest of time in code, we will:- Generate strongly typed models and structure for the fetched content.- Use the content in components- Resolve content from rich text fields into React components- Touch on deployment pipelines and possibilities for discovering content-related issues before hitting production
You will learn:- How to work with content from headless CMS- How content model can be leveraged to generate TS types and what benefits it brings to your project- How not to use string literals for content in code anymore- How to do rich text resolution into React components- How to minimize or avoid content-related issues before hitting production