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.

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
There are many ways of authoring components in React, and doing it right might not be that easy, especially when components get more complex. In this talk, you will learn how to build future-proof React components. We will cover two different approaches to building components - Composition and Configuration, to build the same component using both approaches and explore their advantages and disadvantages.
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
We need to stop building expensive React components — components that promise the world but are impossible to maintain. Let's fight the apropcylpse and set aside our prop drills with this proposal for a more productive way working in React.
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 is not enough. Your dev team has to prefer it over one-off components and third-party libraries. Otherwise, the whole effort is a waste of time. Learn how to use static code analysis to measure if your design system wins over the internal competition and data-driven ways to improve your position.
How to achieve layout composition in React
React Summit 2022React Summit 2022
8 min
How to achieve layout composition in React
Using CSS in this age of components is difficult. Many tools have been created to help us with this problem, but they all fall short in the one problem that tooling can never solve: Which component should be in charge of which styles? In this talk, we will go over strategies on how to build layouts in a composable way.
CCTDD: Cypress Component Test Driven Design
TestJS Summit 2022TestJS Summit 2022
25 min
CCTDD: Cypress Component Test Driven Design
The first part of the talk will focus on a variety of patterns when using Cypress Component Testing and TDD to create React components. The code samples will be from Angular's Tour of Heroes to make the content relatable to a wider community. Currently I am working on a GitBook rewriting it in React using Cypress Component Tests, there should be plenty of content to distill into the talk.The second part of the talk will focus on test strategies, types of testing and where to apply them, and finally compare & contrast them to the familiar industry approaches.We will finish with key takeaways, sample application repos to help with learning, and rollout strategies.
Generic Components with TS and React
React Day Berlin 2022React Day Berlin 2022
10 min
Generic Components with TS and React
What is a generic component? How to write them? When to use it?

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