Accessibility
The ListChoice component has been designed with accessibility in mind, providing interactive list options that can function as buttons or selectable items.
Accessibility Props
The following props are available to improve the accessibility of your ListChoice component:
| Name | Type | Description |
|---|---|---|
| role | string | Specifies the ARIA role of the component. If not provided, the role is set automatically. |
| tabIndex | number | Specifies the tab order of the component. Default is 0, automatically set to -1 when disabled. |
Automatic Accessibility Features
The ListChoice component handles several important ARIA attributes automatically:
aria-disabledis automatically set to match thedisabledprop valuearia-checkedis automatically set to the value of theselectedprop whenselectableis true- Role is automatically determined in this order:
- If a
roleprop is explicitly provided, it will use that value - Otherwise, if
selectableis true, it uses “checkbox” - Otherwise, if
actionis not provided, it uses “button” - If none of these conditions are met, the role will be undefined
- If a
Keyboard Navigation
- Enter or Space keys trigger the
onClickaction when the component is focused - Tab key moves focus to and from the component following the document’s tab order
Best practices
- Provide a descriptive
titlethat clearly explains the purpose of the list item - Use
descriptionto provide additional context when the action isn’t self-explanatory - When using
icon, ensure it visually reinforces the action and is marked as decorative - When using a custom
role, ensure it matches the component’s behavior (e.g., use “link” only if it navigates to another page) - When using the
selectableprop, group related options together and ensure your implementation correctly updates the selected state
Examples
Navigation Option
In this example, the ListChoice functions like a navigation link:
<ListChoicetitle="Flight details"description="View your booking information"icon={<Airplane ariaHidden />}role="link"onClick={() => navigate("/booking-details")}/>
Screen reader announces: “Flight details, View your booking information, link”
Selectable Option in a Group
<Stack><ListChoicetitle="Window seat"selectableselected={selectedSeat === "window"}onClick={() => setSelectedSeat("window")}/><ListChoicetitle="Aisle seat"selectableselected={selectedSeat === "aisle"}onClick={() => setSelectedSeat("aisle")}/></Stack>
Screen reader announces: “Window seat, checkbox, checked” (when selected)
Disabled Option
<ListChoicetitle="Unavailable flight"description="This flight is fully booked"disabledicon={<CloseCircle ariaHidden />}/>
Screen reader announces: “Unavailable flight, This flight is fully booked, button, disabled”
Option with Action Component
<ListChoicetitle="Priority boarding"description="Board the plane first"action={<Button size="small" type="secondary">Add €10</Button>}/>
Screen reader announces: “Priority boarding, Board the plane first” for the ListChoice content and then “Add €10, button” when navigating to the action button.