Guide · Accessibility

How to build an accessible carousel, step by step

A carousel is a list of panels wrapped in controls. Screen readers, keyboards and reduced-motion users need that structure to survive the wrapping. This guide covers the WAI-ARIA carousel pattern and the defaults Zikra Slider Pro applies — with no extra markup.

Updated 2026-11-228 min readLive a11y demo

The pattern in plain language

  • The carousel is a landmark with a name, not a generic pile of divs.
  • Each slide is a group with a position label such as "2 of 5".
  • Off-screen slides are not reachable — neither by tab nor by screen-reader cursor.
  • Page changes are announced politely, without stealing focus.
  • Keyboard users can drive it from the carousel itself.
  • Motion is optional and honors prefers-reduced-motion.

What Zikra generates for you

RequirementDefault behaviorOption
Landmark and namerole="region" + aria-roledescription="carousel"; your host aria-label is keptfeatures.a11y.roleDescription
Slide groupsrole="group", aria-roledescription="slide", aria-label="n of m" — renumbered when slides are added or removedautomatic
Focusable carouseltabindex="0" on the host so keyboard users can reach the arrow-key controlsautomatic
Off-screen isolationaria-hidden="true" + inert on hidden and cloned slidesautomatic
AnnouncementsVisually hidden polite live region: "Slide n of m"features.a11y.liveRegion
Keyboard← → ↑ ↓ Home End PageUp PageDown, when the carousel is focusedfeatures.keyboard
Reduced motionLayout transition replaced by a fadefallback.reducedMotion

All of it is on by default. You can name the carousel and walk away:

<div id="hero" class="zs-slider zs-no-js" aria-label="Featured products">
  <div class="zs-slide">…</div>
  <div class="zs-slide">…</div>
  <div class="zs-slide">…</div>
</div>

<script>
  zikraslider('#hero', { type: 'slide', loop: true });
</script>

Why both aria-hidden and inert?

aria-hidden="true" removes an element from the accessibility tree, but its focusable children can still be reached with Tab. inert makes the subtree non-interactive and unfocusable. Carousels need the pair: aria-hidden stops the screen reader from reading slides that are visually off-screen, and inert stops keyboard focus from disappearing into them. Cloned slides, added for seamless looping, get both from the start.

The active slide stays fully interactive; only off-screen and cloned slides are hidden and inert. When a slide becomes active, both attributes are removed in the same update that moves it into view.

Keyboard support

The host is focusable and listens only when focused by default (onlyWhenFocused: true), so arrow keys still scroll the page elsewhere. The map is:

  • ← / → and ↑ / ↓ — previous / next slide.
  • Home / End — first / last slide.
  • PageUp / PageDown — jump by a page.

Set features.keyboard.onlyWhenFocused to false only if the slider is the page's single primary interaction.

Announcements without noise

After a change, a visually hidden aria-live="polite" region receives "Slide n of m". Updates are debounced by 120 ms so fast drags and autoplay do not flood the screen reader. If your page already has a status line or the slider is decorative, pass features.a11y.liveRegion: false.

Reduced motion

When prefers-reduced-motion: reduce matches, the engine does not run the layout transition; it fades instead (fallback.reducedMotion defaults to 'fade'). Autoplay remains off by default — motion that starts on its own is a separate accessibility problem.

Try it

Focus the slider below with Tab, then use the arrow keys. The full demo's accessibility inspector shows the generated attributes, the inert count, the live region text and the current reduced-motion preference in real time.

Layered rose artwork

Slide one

labelled "1 of 4"

Layered violet artwork

Slide two

off-screen slides are inert

Layered lime artwork

Slide three

changes announce politely

Layered ember artwork

Slide four

Home and End jump to the edges

Testing checklist

  • Tab through the page: focus should reach the carousel once, not every off-screen slide.
  • With the carousel focused, try every arrow key plus Home and End.
  • In VoiceOver or NVDA, confirm the landmark name, the "n of m" labels and the polite announcement after a change.
  • Zoom to 200%: controls stay visible and nothing clips.
  • Enable "reduce motion" at the OS level and confirm slides fade instead of sliding.
  • Call destroy() and confirm the original markup, ARIA and tabindex are gone.

Frequently asked questions

Do I need to add ARIA attributes to a carousel myself?

Not with Zikra Slider Pro. On init it sets role=region and aria-roledescription=carousel on the host, and role=group, aria-roledescription=slide and an "n of m" aria-label on every real slide. Add an aria-label to the host to name the carousel; everything else has a working default.

Why does an accessible carousel use both aria-hidden and inert?

aria-hidden removes an element from the accessibility tree, while inert also blocks focus and pointer events. Used together on off-screen and cloned slides, keyboard and screen-reader users cannot reach content that is not visible. The active slide stays interactive.

How are slide changes announced to screen readers?

A visually hidden polite live region receives "Slide n of m" after each change, debounced by 120 ms. Set features.a11y.liveRegion to false when you already provide your own status text.

Does the carousel respect prefers-reduced-motion?

Yes. When the user prefers reduced motion, the engine swaps the layout transition for a fade; fallback.reducedMotion defaults to 'fade'. The demo's accessibility inspector shows the current media-query result.