For the complete documentation index, see llms.txt. This page is also available as Markdown.

5️⃣Creating custom ARIA widgets

In this chapter, we will explore how to make custom components accessible and user-friendly for everyone using ARIA with the assistance of Flowy.

We will begin by demonstrating how to use Flowy on simple components and then proceed to complex components.

Simple Components

These components are "simple" in that they typically serve a single, specific function and are easy to understand and integrate.

Introduction

A button element is typically used to trigger an action when activated by a user. Think of a button as a remote for doing cool stuff but cool stuff on a website.

Best Practices for Accessible Buttons:

  1. Use a button for triggering actions such as submitting a form, opening a dialog, canceling an action, showing and hiding elements, inserting new information,or displaying information.

  2. Adding role="button" to an element informs assistive technologies to treat the element as a button.

  3. Keyboard support (enter and space keypress) must be provided especially when used on generic elements such as divs or spans.

  4. Ensure to add tabindex="0" on generic elements that have the role="button" so that they can receive keyboard focus and also appear in the tab order.

  5. Elements with role="button" must have labels to identify them. This helps users who rely on assistive technologies to understand the purpose of the button:

  6. Use aria-label to provide accessible labels to a button element or elements with role="button"

How to Fix with Flowy

  1. Determine the elements in your web page that will require to perform specific actions such as such as submitting forms, triggering navigation, triggering hidden content, initiating downloads, or executing JavaScript functions.

  2. Identify the appropriate elements for which you want to enable 'button' functionalities.

  3. Click on the Elements tool and select element.

  4. Select the CSS selectors that will represent the <button> elements for your web page

  5. Choose the attribute <button>, click rock and roll and that’s it.

Sample Code Implementing Button Element Using ARIA


<!-- Using aria-label on button or elements with role="button"--> 
<button type="button" aria-label="Add to Cart"></button>
<div role="button" tabindex="0" aria-label="Close"> X </div>
<span role="button" tabindex="0" aria-label="Save User Interface"> Save UI </span>

Introduction

Lists are used to group together related pieces of information so they are clearly associated with each other and easy to read and understand. Lists are like tidy to-do lists for websites. They keep things organized and easy to follow, like putting your similar items in pairs.

Best Practices for Accessible Lists

  1. Use <ul> when the order of the items does not matter

  2. Use <ol> for when you want to show information in a specific sequence. Example recipe, steps, or instructions.

  3. Avoid using lists for layout purposes. Lists should only be used when representing related items or groups of content.

  4. Avoid making paragraphs that look like lists using bullets symbols or numbers. Instead, format the text content as an <ul> or <ol> depending on your use case.

  5. Adding role="list"(to parent element) and role="listitem"(to children elements) informs assistive technology to treat the element as a list of items. However, this does not differentiate between unordered<ul> or ordered<ol> lists.

How to Fix with Flowy

  1. Determine the elements on your web page that need to be grouped together to associate related pieces of information clearly.

  2. Identify the appropriate elements for which you want to enable structure as list and listitem.

  3. Click on the Elements tool and select element.

  4. Select the css selectors that will represent the list (parent item) and listitem (child elements)

  5. Choose the ‘role’ and attribute <list> for the parent item and <listitem> for the child element.

  6. Click rock and roll and that’s it.

Sample code for Implementing ARIA list

Introduction

The alert role is used to communicate important information to assistive technologies that are available for a specific period of time. Think of an alert role like an alarm, making sure important information reaches the you promptly so that you can take the necessary actions right away.

An sample image demonstrating an example of an alert component. The alert text reads ' Your session will expire in 1 minute"
An example of an Alert Component

Best Accessibility Practices for using role="alert"

  1. Use the "alert" attribute for information that requires the user's immediate attention. For example, a login session that is about to expire or a lost connection.

  2. Using role="alert" informs assistive technologies to treat an element as an ‘alert’ event.

  3. Avoid using "alert" on interactive contents (such as links or buttons). Use only on text content.

  4. The alert role is added to the element containing an alert message.

  5. The alert role does not require any focus management or user interaction.

How to Fix with Flowy

  1. Determine the element(s) on your web page that need to communicate time-sensitive/important information.

  2. Identify the appropriate elements that contain text content that requires a user’s immediate attention.

  3. Click on the Elements tool and select element.

  4. Select the CSS selectors that will represent element(s) with role="alert"

  5. Choose the "role" and the "alert" attribute for your selected element(s)

  6. Click rock and roll and that’s it.

Sample code for implementing alert component with ARIA.

Introduction

The figure role attribute can be utilized in situations where an image, illustration, or diagram has a caption represented by a 'p', 'span', or 'div' element.

Think of it like a label that informs assistive technology that ‘Hey this is a diagram or picture that includes a short description for the image so that users can understand what it represents.

Planet Earth

Best Accessibility Practices for using role="figure"

  1. Using role="figure" informs assistive technologies to treat an element as a figure element.

  2. Use ARIA role="figure" when providing short descriptions of images, illustrations, diagrams, audio, code snippets, video, or other multimedia elements.

  3. Use an aria-label when there is no visible text caption.

  4. Use an aria-labelledby when there is a visible text caption.

  5. Use aria-describedby when the present text has a longer description

How to Fix with Flowy

  1. Determine the multimedia (images, code snippets, or diagrams) elements on your web page that need to be grouped together to associate related pieces of information clearly.

  2. Identify the appropriate elements for which you want to implement role="figure"

  3. Click on the Elements tool and select element.

  4. Select the CSS selectors that will represent the ARIA "figure" role.

  5. Choose the "role" and the "figure" attribute for your selected element(s)

  6. Provide an accessible name or description depending on your use case. Use an aria-label when there is no visible text caption. Use aria-labelledby when there is a visible text caption. Use aria-describedby when the present text has a longer description.

  7. Click rock and roll and that’s it!

Sample code for creating a figure element with ARIA

Introduction

The progress bar role defines an element that displays the progress status for tasks that take a certain amount of time to complete. This ARIA role is like a progress navigator, letting you know exactly how far you've come and how much further you have to go, "You're 50% there! Keep going!".

A progress bar showing 50% completion, marked with a blue color.
An example of an ARIA progress bar component.

Best Accessibility Practices for using role="Progress"

  1. Using role="progress" informs assistive technologies that an element presents the progress status for tasks.

  2. Use the aria-valuenow attribute to indicate the current value of the progress bar. This attribute is mandatory.

  3. Use the aria-valuemin to indicate the minimum value of the progress bar. This attribute is optional.

  4. Use the aria-valuemax to indicate the maximum value of the progress bar. This attribute is optional.

  5. Ensure to implement role='status' and aria-atomic='true' so that assistive technologies will automatically announce any updates to the status.

  6. Use the aria-label attribute when the title is not visible.

  7. Use the aria-labelledby attribute when there is visible text to provide an accessible label to the ARIA progress bar.

Sample Code for Creating a Progress Bar with ARIA

Introduction

The ARIA radiogroup is a role given to a group of ARIA radio buttons. On the other hand, an ARIA radio element allows users to make only one selection at a time.

An example of ARIA radio group content. The content reads "What is your favorite color?"This is followed by two options ,'purple and Aubergine'. The option 'purple is already selected.
An example of an ARIA radio group component.

Best Accessibility Practices for using role=”radiogroup” and role=”radio”

  1. Using role='radiogroup' informs assistive technologies of the presence of a set of related radio buttons.

  2. Using role=”radio” informs assistive technologies to treat the elements as radio buttons.

  3. The 'aria-checked' attribute, set to true or false, must be added to individual radio buttons. This will inform assistive technologies of the selected or unselected states.

  4. The radiogroup must have an accessible name.It can be achieved through a visible label referenced by aria-labelledby or a label specified with aria-label

  5. Use aria-describedby attribute to reference elements providing additional information about the radiogroup.

  6. Tabindex (tabindex=”0”) must be implemented to ensure the elements are focusable and are included in the tab order of your website.

  7. Ensure keyboard support: The space key checks or unchecks the button. The Right Arrow or Down Arrow moves focus to the next radio button, and the Left Arrow or Up Arrow moves focus to the previous radio button.

How to Implement with Flowy

  1. Determine the elements in your page that provide ‘radio’ button functionalities..

  2. Identify the appropriate elements for which you want to implement role=’"radiogroup" and role="radio".

  3. Click on the Elements tool and select element.

  4. Select the CSS selectors that will represent the ARIA "radiogroup" and ‘ARIA radio buttons’.

  5. Choose the ‘role’ and the attribute "radiogroup" attribute for element(s) serving as a container for the radio buttons.

  6. Choose the "role" and the attribute "radio" for element(s) serving individual radio buttons.

  7. Provide an accessible name or description depending on your use case. Use an aria-label when there is no visible text caption. Use aria-labelledby when there is a visible text caption. Use aria-describedby when the present text has a longer description.

  8. Click rock and roll and that’s it.

Sample Code for Implementing an ARIA radiogroup and radio

Complex Components

These are components involve multiple functionalities, states, or even nested components. These are designed to handle more complex interactions

A combobox is a component/widget that allows users to select a value from a predefined set list of options presented in a dropdown list or popup item. Imagine a combobox as a magical box that lets you choose something from a bunch of cool options.

A combobox can take the form of a widget that supports editing or typing, or it can be in the form of a widget that only displays content. A common component is the calender or datepicker.

A screenshot of a combobox sample. The component has a search functionality and dropdown functionality that allows users to type or select items from the dropdown.
A sample combobox component
A sample combobox component

Best Accessibility Practices for using role="combobox"

  1. Using role="combobox" informs assistive technologies to treat an element as a combobox.

  2. The element with the role "combobox" must have the ‘aria-controls’ attribute to communicate to assistive technologies the relationship between the combobox and the popup element

  3. The element with the role "combobox" must have an " aria-expanded" attribute to communicate to assistive technologies the shown and hidden states of the popup elements.

  4. Tabindex (tabindex=”0”) must be implemented to ensure the elements are focusable and are included in the tab order of your website.

How to Fix with Flowy

  1. Determine the element(s) on your web page that requires a user to select a value from a predefined set list of options presented in a dropdown list or popup item.

  2. Identify the appropriate elements that contain items that users can select a value from a predefined set list of options presented in a dropdown list or popup item.

  3. Click on the Elements tool and select element.

  4. Select the CSS selectors that will represent element(s) with role=”combobox”

  5. Choose the 'role' and the ‘checkbox’ attribute for your selected element(s).

  6. Choose the 'aria-controls' attribute to match the dropdown list or popup item ID attribute.

  7. Choose the ‘aria-expanded’ attribute initially set to false. When the popup/dropdown element is visible, aria-expanded is set to true.

  8. Provide accessible labels(names) with the ‘aria-label’ or ‘aria-labelledby’ attributes so that assistive technologies can understand the purpose of the checkboxes.

  9. Click rock and roll and that’s it.

Sample Code Snippet for Implementing a Combobox Using ARIA.

An accordion is a component that helps organize content in a collapsible and expandable manner. Just like when you're trying to store a large musical instrument in a tiny closet, an accordion component allows you to tuck away a lot of content neatly, conserving precious space on your web page.

A sample accordion with collapsible panels. The accordion consists of three headings titled 'Heading 1,' 'Heading 2,' and 'Heading 3.' Each heading is succeded by some 'Lorem Ipsum' texts
A sample Accordion component

Best Accessibility Practices for an Accordion

  1. Ensure that the button element is nested inside the header element.

  2. Tabindex (tabindex=”0”) must be implemented to ensure the elements are focusable and are included in the tab order of your website.

  3. Ensure that each button within an accordion header, is associated with its corresponding panel by using aria-controls.

  4. Ensure that each button has the aria-expanded attribute to communicate the visibility and hidden states of the panel.

How to Fix with Flowy

  1. Determine and identify the element(s) on your web page will serve as the accordion headers, buttons and the corresponding <div> elements will be the content panels that expand and collapse.

  2. Click on the Elements tool and select element.

  3. Select the CSS selectors that will represent element(s) for headings, buttons, and content panels.

  4. Choose each role for the heading and button for your selected element(s). For the heading element(s): use 'role' with the value 'heading', and specify the heading level using the 'aria-level' attribute (e.g., 'aria-level="2"' represents heading level 2).

  5. For button element(s): use ‘role’ with the value of button, and a tabindex=”0”. Select the ‘aria-expanded’ attribute and set its initial value to false. Select the’aria-controls’ attribute and set its value to the id content of the panel.

  6. Provide accessible labels(names) with the ‘aria-labelledby’ attribute referencing the id of the button(s)

  7. Click rock and roll and that's it!

Sample Code Snippet for Implementing an Accordion with ARIA.

Introduction

Tabs consist of multiple sections of content called tab panels. These panels display one section of content at a time. Each tab panel corresponds to a tab element, which, when activated, reveals the respective panel.Tabs are like a fancy restaurant menu where each tab panel displays a delicious dish.

Sample tab component consisting of four panels showing Equally services namely: File Accessibility, Media Accessibility, Mobile App Testing and VPAT testing
Sample Tab panels

Best Accessibility Practices for a Tab component

  1. Using role="tablist" on an element informs assistive technologies to treat the element as tablist.

  2. The container holding the set of tabs has the role="tablist".

  3. Individual tab elements have role="tab".

  4. Elements with role="tab" must have the ‘aria-controls’ attribute to refere to its associated tabpanel.

  5. The element that contains content has the role="tabpanel".

  6. Provide accessible names to the element with the role="tablist" with using aria-label or aria-labelledby techniques.

  7. The current active tab element must be highlighted using aria-selected="true".

  8. Every tabpanel has a name that is easily accessible through "aria-labelledby," referring to the tab element it is associated with.

How to Fix with Flowy

  1. Determine the element(s) on your web page that display multiple but display content one at a time

  2. Identify the appropriate elements that will comprise thetablist component

  3. Click on the Elements tool and select the appropriate elements

  4. Select the css selectors that will do the following: Represent element(s) with role="tablist" This will be the main container for the set of tabs.Represent element(s) with role="tab" to identify the element(s) that serves tab elements. Represent element(s) with role="tabpanel"to identify each element that contains content for the panel.

  5. Choose all the ARIA roles and their respective attribute(s) as laid out in step number 4 for your selected element(s).

  6. Provide accessible name using ‘aria-label’ attribute on element with the role=”tablist” and aria-labelledby on the element with the role=”tabpanel”

  7. Click rock and roll and that’s it.

Sample Code Snippert of Implementing a Tablist using ARIA

Introduction

It typically appears as a window or popup that temporarily interrupts the normal flow of an application to capture the user's attention or gather specific information. One important thing to keep in mind is that when a dialog is active, users cannot interact with contents outside the dialog.

A screenshot of sample dialog component. The dialog is a signup from for equally. The form contain three input fields: first name, last name and email.
A sample Dialog Component

Best Accessibility Practices for using role="dialog"

  • Using role="dialog" on an element informs assistive technologies to treat the element as a dialog.

  • Ensure focus moves to the first interactive element when the dialog is open.

  • Ensure keyboard support for the component. The ‘tab’ key moves focus to the next interactive element, "shift + tab" moves focus to the previous interactive element, and the "Esc" key closes the dialog.

  • An accessible label/name can be provided with the 'aria-label' and 'aria-labelledby' attributes.

  • Ensure that users cannot interact with content outside an active dialog.

How to Fix with Flowy

  1. Determine the element(s) on your web page that appear as an interactive window or popup component separate from the main content.

  2. Identify the appropriate elements that are dialog elements

  3. Click on the Elements tool and select element.

  4. Select the CSS selectors that will represent element(s) with role="dialog"

  5. Choose the "role" and the "dialog" attribute for your selected element(s)

  6. Provide accessible labels (names) using the 'aria-labelledby' attribute and reference the title element inside the dialog. This will enable assistive technologies to understand the purpose of the dialog

  7. Click rock and roll and that’s it!

Sample Code Snippet for Implementing a Dialog Component with ARIA

Introduction

ARIA table is a static table-like structure without interactive features, and its cells are not focusable or selectable.

Best Accessibility Practices for using role=”table”.

  1. Using role="table" on an element informs assistive technologies to treat the element as table.

  2. An ARIA table must contain role="rowgroup" to organize or structure the table's content as needed.

  3. An ARIA table must contain role="row" on the container holding the ARIA table cells, column headers, or row headers.

  4. An ARIA table must contain role="columnheader"’. This defines the title or header information for the column.

  5. An ARIA table must contain role="rowheader". This defines the title or header information for the column.

  6. An ARIA table must contain ‘role=cell’. This Identifies elements containing content for a single cell.

  7. An accessible label/name can be provided with the 'aria-label' and 'aria-labelledby' attributes.

  8. An ARIA table must have an accessible label/name. This can be provided with the 'aria-label' or 'aria-labelledby' attributes.

  9. In the event a description of an ARIA table is present, use the 'aria-describedby' attribute as a reference to provide a description for the table.

How to Fix with Flowy

  1. Determine the element(s) on your web page that hold any form of data that is presented to users.

  2. Identify the appropriate elements that will comprise all the table elements. This includes rowgroups,rowheader,columnheader, rows and cells.

  3. Click on the Elements tool and select the appropriate elements.

  4. Select the CSS selectors that will: Represent element(s) with role="table".This will be the main container holding all the table contents. Represent element(s) with role="rowgroup" to identify the elements that serve as containers for the table header and table body rows. Represent element(s) with role="row" to identify each element that contains the cells for a row. Represent element(s) with role="columnheader" to Identify elements that serve as a cell(s) containing a column label. Represent element(s) with role="columnheader" Identifies elements containing content for a single cell.

  5. Choose the choose all the ARIA roles and their respective attribute(s) as laid out in step number 4 for your selected element(s)

  6. Provide accessible name or description depending on your use case. Use aria-label when there is no visible text caption. Use aria-labelledby when there is a visible text caption. Use aria-describedby if present to provide a description for the table.

  7. Click rock and roll and that’s it!

Sample Code Snippet for Creating a Table with ARIA

Introduction

The role="checkbox" is for check-able interactive elements. An element with role="checkbox" is comprised of three states namely true(checked) and false(unchecked) Some of the use cases for using aria role of checkbox include multiple selections, agree/disagree selections, task completion, filtering and sorting, and settings and preferences.

A screenshot of a sample checkbox component, listing days of the week.  The days displayed are Monday to Thursday with Wednesday being the only day that is checked.
A sample checkbox listing days of the week

Best Accessibility Practices for using role="checkbox"

  1. Using role="checkbox" on an element informs assistive technologies to treat the element as a checkbox.

  2. Keyboard support must be provided. The "space" key must check or unchecked an item.

  3. Tabindex (tabindex="0") must be implemented to ensure the elements are focusable and are included in the tab order of your website.

  4. The "aria-checked" attribute must be implemented to ensure the checked and unchecked states are communicated to assistive technologies.

  5. In cases where the visual text (labels) is missing, To provide accessible names to the elements, aria-label or aria-labelledby attributes can be used.

How to Fix with Flowy

  1. Determine the element(s) on your web page that requires a user to choose more than one item from a list

  2. Identify the appropriate elements that contain items that users can select(check)

  3. Click on the Elements tool and select element.

  4. Select the CSS selectors that will represent element(s) with role="checkbox"

  5. Choose the "role" and the "checkbox" attribute for your selected element(s)

  6. Provide accessible labels(names) with the "aria-label" or "aria-labelledby" attributes so that assistive technologies can understand the purpose of the component.

  7. Click rock and roll and that’s it.

Sample Code Snippet for Implementing Checkbox with ARIA

Last updated