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 link <a> is an interactive element that allows you to navigate from one web page to another, an external document ,or to a different section within the same web page.
Best Practices for Accessible Links
Links should have clear descriptions that tell users where they'll go when they click them. This provides context and helps users understand the link's purpose before they click.
Avoid the use of terms such as βView hereβ, βClick hereβ, βmore informationβ or βread hereβ. If there isn't enough information around the link, people using assistive technologies may have trouble understanding the purpose of the link.
Adding
role=βlinkβon elements informs assistive technologies to treat the element as a linkKeyboard support(enter key to activate a link) must be provided especially when used on generic elements such as
divsandspans.Provide a clear visual focus indication for links when they receive keyboard focus.
If the link text is not clear enough, you can use
"aria-label"attribute to add more information. This provides context for users relying on assistive technologies to understand where the link will lead them or what it does.Use
aria-labelto provide accessible labels to link elements or provide additional context for users relying on assistive technology.
How to Fix with Flowy
Determine the elements in your web page that will require users to click, or tab to perform specific actions such as navigating from one web page to another, navigating to an external document, or to a different section within the same web page
Identify the appropriate elements for which you want to enable
'link'functionalities.Click on the Elements tool and select element.
Select the CSS selectors that will represent the link
<a>elements for your web pageChoose the attribute
<a>(link), click rock and roll and thatβs it.
Code Sample for Implementing Links with ARIA
<!-- Using aria-label on link or elements with role="link" -->|
<a href="#" aria-label="Read more about Flowy"> Read More </a>
<div role="link" tabindex="0" aria-label="View more details about flowy"> View More
</div>
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
Use
<ul>when the order of the items does not matterUse
<ol>for when you want to show information in a specific sequence. Example recipe, steps, or instructions.Avoid using lists for layout purposes. Lists should only be used when representing related items or groups of content.
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.Adding
role="list"(to parent element) androle="listitem"(to children elements) informs assistive technology to treat the element as alistof items. However, this does not differentiate between unordered<ul>or ordered<ol>lists.
How to Fix with Flowy
Determine the elements on your web page that need to be grouped together to associate related pieces of information clearly.
Identify the appropriate elements for which you want to enable structure as list and
listitem.Click on the Elements tool and select element.
Select the css selectors that will represent the
list(parent item) andlistitem(child elements)Choose the βroleβ and attribute <list> for the parent item and
<listitem>for the child element.Click rock and roll and thatβs it.
Sample code for Implementing ARIA list
<!-- using ARIA --> <div role="list">
<div role="listitem"> Monday </div>
<div role="listitem">Tuesday</div>
</div>
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.

Best Accessibility Practices for using role="alert"
role="alert" 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.Using
role="alert"informs assistive technologies to treat an element as an βalertβ event.Avoid using "
alert"on interactive contents (such as links or buttons). Use only on text content.The
alert roleis added to the element containing an alert message.The
alert roledoes not require any focus management or user interaction.
How to Fix with Flowy
Determine the element(s) on your web page that need to communicate time-sensitive/important information.
Identify the appropriate elements that contain text content that requires a userβs immediate attention.
Click on the Elements tool and select element.
Select the CSS selectors that will represent element(s) with
role="alert"Choose the "
role"and the"alert"attribute for your selected element(s)Click rock and roll and thatβs it.
Sample code for implementing alert component with ARIA.
<div role="alert">
Your log in session will expire in 1 minute
</div>
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.

Best Accessibility Practices for using role="figure"
role="figure"Using r
ole="figure"informs assistive technologies to treat an element as a figure element.Use ARIA
role="figure"when providing short descriptions of images, illustrations, diagrams, audio, code snippets, video, or other multimedia elements.Use an
aria-labelwhen there is no visible text caption.Use an
aria-labelledbywhen there is a visible text caption.Use
aria-describedbywhen the present text has a longer description
How to Fix with Flowy
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.
Identify the appropriate elements for which you want to implement
role="figure"Click on the Elements tool and select element.
Select the CSS selectors that will represent the ARIA
"figure"role.Choose the "
role"and the"figure"attribute for your selected element(s)Provide an accessible name or description depending on your use case. Use an
aria-labelwhen there is no visible text caption. Usearia-labelledbywhen there is a visible text caption. Usearia-describedbywhen the present text has a longer description.Click rock and roll and thatβs it!
Sample code for creating a figure element with ARIA
<!-- ARIA figure using aria-label -->
<div role="figure" aria-label="Planet earth known to support life "> <img src="earth.jpg" alt="A satelite view of Earth">
</div>
<!-- ARIA figure using aria-labelledby -->
<div role="figure" aria-labelledby="figure1">
<img src="earth.jpg" alt="A satelite view of Earth">
<p id="figure1">Planet earth known to support life </p> </div>
<!-- ARIA figure using aria-describedby -->
<div role="figure" aria-labelledby="">
<img src="earth.jpg" alt="A satellite view of Earth">
surface is
<p id="figure1">Planet Earth known to support life. It's divided into seven continents: Asia, Africa, North America, South America, Antarctica, Europe, and Australia</p>
</div>
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!".

Best Accessibility Practices for using role="Progress"
role="Progress"Using
role="progress"informs assistive technologies that an element presents the progress status for tasks.Use the
aria-valuenowattribute to indicate the current value of the progress bar. This attribute is mandatory.Use the
aria-valueminto indicate the minimum value of the progress bar. This attribute is optional.Use the
aria-valuemaxto indicate the maximum value of the progress bar. This attribute is optional.Ensure to implement
role='status'andaria-atomic='true'so that assistive technologies will automatically announce any updates to the status.Use the aria-label attribute when the title is not visible.
Use the
aria-labelledbyattribute when there is visible text to provide an accessible label to the ARIA progress bar.
Sample Code for Creating a Progress Bar with ARIA
<!-- Using aria-label -->
<div role="progressbar" aria-valuenow="50" aria-label="Loading: 50%"
role="status" aria-atomic="true"></div>
<!-- Using aria-labelledby -->
<div role="progressbar" aria-valuenow="75" aria-labelledby="progress-label" role="status" aria-atomic="true"></div>
<p id="progress-label" class="sr-only">Uploading: 75% complete</p>
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.

Best Accessibility Practices for using role=βradiogroupβ and role=βradioβ
Using
role='radiogroup'informs assistive technologies of the presence of a set of related radio buttons.Using
role=βradioβinforms assistive technologies to treat the elements as radio buttons.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.
The
radiogroupmust have an accessible name.It can be achieved through a visible label referenced by aria-labelledby or a label specified with aria-labelUse aria-describedby attribute to reference elements providing additional information about the
radiogroup.Tabindex
(tabindex=β0β)must be implemented to ensure the elements are focusable and are included in the tab order of your website.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
Determine the elements in your page that provide βradioβ button functionalities..
Identify the appropriate elements for which you want to implement
role=β"radiogroup"androle="radio".Click on the Elements tool and select element.
Select the CSS selectors that will represent the ARIA "
radiogroup"and βARIA radio buttonsβ.Choose the βroleβ and the attribute "
radiogroup"attribute for element(s) serving as a container for the radio buttons.Choose the "
role"and the attribute "radio"for element(s) serving individual radio buttons.Provide an accessible name or description depending on your use case. Use an
aria-labelwhen there is no visible text caption. Usearia-labelledbywhen there is a visible text caption. Usearia-describedbywhen the present text has a longer description.Click rock and roll and thatβs it.
Sample Code for Implementing an ARIA radiogroup and radio
<!--ARIA radiogroup and radio -->
<div role="radiogroup" aria-labelledby="question">
<div id="question">What is your favorite color?/div> <div id="radioGroup">
<span id="colorOption_0" tabindex="0" role="radio" aria-
checked="true"
aria-labelledby="purple"></span>
<span id="purple">Purple</span>
<span id="colorOption_1" tabindex="-1" role="radio" aria-
checked="false"
</div>
aria-labelledby="aubergine"></span>
<span id="aubergine">Aubergine</span>
</div>
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.


Best Accessibility Practices for using role="combobox"
role="combobox"Using
role="combobox"informs assistive technologies to treat an element as acombobox.The element with the
role "combobox"must have the βaria-controlsβ attribute to communicate to assistive technologies the relationship between thecomboboxand the popup elementThe 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.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
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
dropdownlist or popup item.Identify the appropriate elements that contain items that users can select a value from a predefined set list of options presented in a
dropdownlist or popup item.Click on the Elements tool and select element.
Select the CSS selectors that will represent element(s) with
role=βcomboboxβChoose the '
role'and the βcheckboxβ attribute for your selected element(s).Choose the
'aria-controls'attribute to match thedropdownlist or popup item ID attribute.Choose the βaria-expandedβ attribute initially set to false. When the
popup/dropdownelement is visible, aria-expanded is set to true.Provide accessible labels(names) with the βaria-labelβ or βaria-labelledbyβ attributes so that assistive technologies can understand the purpose of the checkboxes.
Click rock and roll and thatβs it.
Sample Code Snippet for Implementing a Combobox Using ARIA.
Combobox Using ARIA.
<!-- ARIA combobox -->
<input type="text" role=" combobox" aria- expanded="false" aria-autocomplete="list" aria- controls="exl-grid" id="ex1-input">
<div aria-labelledby="cb-label" id="grid"></div>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.

Best Accessibility Practices for an Accordion
Ensure that the button element is nested inside the header element.
Tabindex
(tabindex=β0β) must be implemented to ensure the elements are focusable and are included in the tab order of your website.Ensure that each button within an accordion header, is associated with its corresponding panel by using aria-controls.
Ensure that each button has the aria-expanded attribute to communicate the visibility and hidden states of the panel.
How to Fix with Flowy
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.Click on the Elements tool and select element.
Select the CSS selectors that will represent element(s) for headings, buttons, and content panels.
Choose each
rolefor theheadingandbuttonfor 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).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.Provide accessible labels(names) with the
βaria-labelledbyβattribute referencing the id of the button(s)Click rock and roll and that's it!
Sample Code Snippet for Implementing an Accordion with ARIA.
<!-- Accordion code structure using ARIA-->
<div role="heading" aria-level="2">
<span role="button" tabindex="0" id="accordion-header-1" aria-
expanded="true"
aria-controls="accordion-panel-1">
Your title here
</span>
</div>
<div id="accordion-panel-1" role="region" aria-labelledby="accordion-
header-1">
<p>Accordion content here...</p>
</div>
<div>Introduction
The carousel is a slideshow that shows different content one after the other. With a Carousel , users can use controls to switch between slides in the carousel, hiding the current slide and showing the next or previous one as they "rotate" through the content.

Best Accessibility Practices for a Carousel
The container holding the carousel elements has the
role='region'if you intend to mark the area as a landmark orrole='group'if you intend not to mark the content as a landmark region.Provide an accessible label on the carousel container using the "
aria-label"attribute.Previous and next slide controls(the carousel arrows) must have
role="button"with atabindex="0"and an"aria-label"to indicate its purpose.Use
role="group"and an βaria-labelβ attribute on individual slides to know where each slide begins and ends.Use
aria-current="true"on the button of the slide dot corresponding to the currently active slide so that screen reader users are informed.Provide an accessible label on each of he button of the slide dot using the
βaria-labelattribute.Ensure keyboard support: The "
tab"key to move through interactive βdotβ buttons. Enter and space to display the next or previous slide in the carousel/slideshow.
How to Fix with Flowy
Determine the element(s) on your web page that contain Carousel/slideshow content.
Identify the appropriate elements that will comprise of all the Carousel elements.
Click on the Elements tool and select the appropriate elements
Select the CSS selectors that will do the following: Represent element(s) with
role="region"orrole=βgroupβ(depending on importance). This will be the main container holding all the Carousel/Slideshow elements. Represent element(s) withrole="group"to identify the elements that serve as containers for the individual slides. Represent element(s) withrole="button"to identify each element serves as the previous and next slide controls (the arrows). Represent element(s) withrole="button"to identify elements that serve as button of the slide dot(s)Choose all the ARIA roles and their respective attribute(s) as laid out in step number 4 for your selected element(s). All elements with 'role=button' must have
'tabindex=0'to be focusable and in the natural tab order.Provide accessible name using the βaria-labelβ attribute on the main Carousel container with the
role="region",on the individual slide container(s) with therole="group". (Example:slide 1 of 5),On the individual βdot buttonsβ with role=βbuttonβ. (Example :Go to Slide 1β).Click rock and roll and thatβs it.
Sample Code Snippet of a Carousel Using ARIA
<!-- Carosel using ARIA -->
<div class="carousel" role='region' aria-label="carousel"> <div role="button" tabindex="0" aria-label="previous slide"> < </div>
<div class="slide" role="group" aria label="slide 1 of 2"> Slide content here...
</div>
<div class="slide" role="group" aria-label="slide 2 of 2"> Slide content here ..
</div>
<div role="button" tabindex="0" aria-label="next slide"> > </div>
<div class="dot-button">
<div role="button" tabindex="0" aria-label="previous slide"> Go to slide 1</div>
<div role="button" tabindex="0" aria-label="previous
slide"> Go to slide 2</div>
</div>
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.

Best Accessibility Practices for a Tab component
Using
role="tablist"on an element informs assistive technologies to treat the element astablist.The container holding the set of tabs has the
role="tablist".Individual tab elements have
role="tab".Elements with
role="tab"must have the βaria-controlsβ attribute to refere to its associated tabpanel.The element that contains content has the
role="tabpanel".Provide accessible names to the element with the
role="tablist"with using aria-label or aria-labelledby techniques.The current active tab element must be highlighted using
aria-selected="true".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
Determine the element(s) on your web page that display multiple but display content one at a time
Identify the appropriate elements that will comprise the
tablistcomponentClick on the Elements tool and select the appropriate elements
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) withrole="tab"to identify the element(s) that serves tab elements. Represent element(s) withrole="tabpanel"to identify each element that contains content for the panel.Choose all the ARIA roles and their respective attribute(s) as laid out in step number 4 for your selected element(s).
Provide accessible name using βaria-labelβ attribute on element with the role=βtablistβ and aria-labelledby on the element with the role=βtabpanelβ
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.

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
dialogis 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
Determine the element(s) on your web page that appear as an interactive window or popup component separate from the main content.
Identify the appropriate elements that are
dialogelementsClick on the Elements tool and select element.
Select the CSS selectors that will represent element(s) with
role="dialog"Choose the "
role"and the "dialog"attribute for your selected element(s)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
Click rock and roll and thatβs it!
Sample Code Snippet for Implementing a Dialog Component with ARIA
<div role="dialog"
aria-labelledby="dialog1Title">
<h2 id="dialog1Title">Equally Subscription Form</h2>
<!--form contents -->
</div>
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β.
Using
role="table"on an element informs assistive technologies to treat the element as table.An ARIA table must contain
role="rowgroup"to organize or structure the table's content as needed.An ARIA table must contain
role="row"on the container holding the ARIA table cells,column headers, orrow headers.An ARIA table must contain
role="columnheader"β. This defines the title or header information for the column.An ARIA table must contain
role="rowheader". This defines the title or header information for the column.An ARIA table must contain βrole=cellβ. This Identifies elements containing content for a single cell.
An accessible label/name can be provided with the
'aria-label' and 'aria-labelledby'attributes.An ARIA table must have an accessible label/name. This can be provided with the
'aria-label' or'aria-labelledby'attributes.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
Determine the element(s) on your web page that hold any form of data that is presented to users.
Identify the appropriate elements that will comprise all the table elements. This includes
rowgroups,rowheader,columnheader,rowsandcells.Click on the Elements tool and select the appropriate elements.
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) withrole="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.Choose the choose all the
ARIAroles and their respective attribute(s) as laid out in step number 4 for your selected element(s)Provide accessible name or description depending on your use case. Use
aria-labelwhen there is no visible text caption. Usearia-labelledbywhen there is a visible text caption. Usearia-describedbyif present to provide a description for the table.Click rock and roll and thatβs it!
Sample Code Snippet for Creating a Table with ARIA
ο»Ώ
βΌ <!-- ARIA Table -->
<div id="table" role="table" aria-label="Table Name" aria- describedby="table_caption">
<div id="table_caption">Table description</div>
<div role="rowgroup">
<div role="row">
<div role="column header">Header 1</div>
<div role="columnheader">Header 2</div>
<div role="column header">Header 3</div> </div>
</div>
<div role="rowgroup">
<div role="row">
<div role="rowheader">Row 1 Header</div> <div role="cell">Row 1 Data 1</div>
<div role="cell">Row 1 Data 2</div> </div>
</div>
</div>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.

Best Accessibility Practices for using role="checkbox"
role="checkbox"Using
role="checkbox"on an element informs assistive technologies to treat the element as a checkbox.Keyboard support must be provided. The "
space"key must check or unchecked an item.Tabindex (
tabindex="0") must be implemented to ensure the elements are focusable and are included in the tab order of your website.The "
aria-checked"attribute must be implemented to ensure the checked and unchecked states are communicated to assistive technologies.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
Determine the element(s) on your web page that requires a user to choose more than one item from a list
Identify the appropriate elements that contain items that users can select(check)
Click on the Elements tool and select element.
Select the CSS selectors that will represent element(s) with
role="checkbox"Choose the
"role"and the"checkbox"attribute for your selected element(s)Provide accessible labels(names) with the
"aria-label"or"aria-labelledby"attributes so that assistive technologies can understand the purpose of the component.Click rock and roll and thatβs it.
Sample Code Snippet for Implementing Checkbox with ARIA
ο»Ώ
<!-- using ARIA role and aria-label -->
<span role="checkbox" aria-checked="true" tabindex="0" aria-label ="I agree to Equally terms"></span>
<p> I agree to Equally terms </p>
<!-- using ARIA role and aria-labelledby -->
<span role="checkbox" aria-checked="true" tabindex="0" aria- labelledby="cb-label"></span>
<label id="cb-label"> I agree to Equally Terms </label>
Last updated
