third_party/aria-practices/src/content/patterns/carousel/carousel-pattern.html
A carousel presents a set of items, referred to as slides, by sequentially displaying a subset of one or more slides. Typically, one slide is displayed at a time, and users can activate a next or previous slide control that hides the current slide and "rotates" the next or previous slide into view. In some implementations, rotation automatically starts when the page loads, and it may also automatically stop once all the slides have been displayed. While a slide may contain any type of content, image carousels where each slide contains nothing more than a single image are common.
Ensuring all users can easily control and are not adversely affected by slide rotation is an essential aspect of making carousels accessible. For instance, the screen reader experience can be confusing and disorienting if slides that are not visible on screen are incorrectly hidden, e.g., displayed off-screen. Similarly, if slides rotate automatically and a screen reader user is not aware of the rotation, the user may read an element on slide 1, execute the screen reader command for next element, and, instead of hearing the next element on slide 1, hear an element from slide 2 without any knowledge that the element just announced is from an entirely new context.
Features needed to provide sufficient rotation control include:
The following terms are used to describe components of a carousel.
SlideA single content container within a set of content containers that hold the content to be presented by the carousel.Rotation ControlAn interactive element that stops and starts automatic slide rotation.Next Slide ControlAn interactive element, often styled as an arrow, that displays the next slide in the rotation sequence.Previous Slide ControlAn interactive element, often styled as an arrow, that displays the previous slide in the rotation sequence.Slide Picker ControlsA group of elements, often styled as small dots, that enable the user to pick a specific slide in the rotation sequence to display.
This section describes the element composition for three styles of carousels:
A carousel container element that encompasses all components of the carousel, including both carousel controls and slides, has either role region or role group. The most appropriate role for the carousel container depends on the information architecture of the page. See the Landmark Regions Practice to determine whether the carousel warrants being designated as a landmark region.
The carousel container has the aria-roledescription property set to carousel.
If the carousel has a visible label, its accessible label is provided by the property aria-labelledby on the carousel container set to the ID of the element containing the visible label. Otherwise, an accessible label is provided by the property aria-label set on the carousel container. Note that since the aria-roledescription is set to "carousel", the label does not contain the word "carousel".
The rotation control, next slide control, and previous slide control are either native button elements (recommended) or implement the button pattern.
The rotation control has an accessible label provided by either its inner text or aria-label. The label changes to match the action the button will perform, e.g., "Stop slide rotation" or "Start slide rotation". A label that changes when the button is activated clearly communicates both that slide content can change automatically and when it is doing so. Note that since the label changes, the rotation control does not have any states, e.g., aria-pressed, specified.
Each slide container has role group with the property aria-roledescription set to slide.
Each slide has an accessible name:
aria-roledescription is set to "slide", the label does not contain the word "slide."Optionally, an element wrapping the set of slide elements has aria-atomic set to false and aria-live set to:
off: if the carousel is automatically rotating.polite: if the carousel is NOT automatically rotating.The structure of a tabbed carousel is the same as a basic carousel except that:
group, and it does not have the aria-roledescription property.tab element, so activating a tab displays the slide associated with that tab.tab indicates which slide it will display by including the name or number of the slide, e.g., "Slide 3". Slide names are preferable if each slide has a unique name.tablist element with an accessible name provided by the value of aria-label that identifies the purpose of the tabs, e.g., "Choose slide to display."tab, tablist, and tabpanel implement the properties specified in the tabs pattern.A grouped carousel has the same structure as a basic carousel, but it also includes slide picker controls where:
group element.true. Note: aria-disabled is preferable to the HTML disabled attribute because this is a circumstance where screen reader users benefit from the disabled button being included in the page Tab sequence.