CodingLaboratory
Lab Commands
Enter The Lab

Frontend field guide / accessible-carousel

10 min
Interactive UI Patterns 10 min Updated

Accessible carousel design without autoplay traps

Build carousels with clear controls, stable focus, optional autoplay, semantic slide labels, swipe support, and reduced motion.

accessible carouselcarousel autoplay accessibilityswipe galleryslider controls

What you will build correctly

  • Default to user-controlled movement and stop autoplay after interaction.
  • Label the region, slides, and previous/next controls clearly.
  • Keep focus stable while visual slides change around it.
02

Give the region and controls direct names

Label the carousel by its content, such as “Customer stories” or “Product photos.” Use buttons named “Previous slide” and “Next slide,” and expose the current position with concise text such as “Slide 2 of 5.” Dot controls need names that identify their destination.

Keep controls in a predictable location and large enough for touch. Disabled boundaries in a non-looping carousel should be visible, while an infinite loop must not create duplicated focusable content from cloned slides.

A named carousel with clear controls
                      <section aria-roledescription="carousel" aria-label="Product photos">
  <button aria-label="Previous slide">…</button>
  <p aria-live="polite">Slide 2 of 5</p>
  <button aria-label="Next slide">…</button>
</section>
                    
03

Manage hidden slides and focus

Only the active slide should expose interactive descendants when off-screen slides are visually unavailable. Use inert or remove them from the tab order, but avoid destroying user-entered state when slides represent steps in a form.

Activating next or previous should usually keep focus on the control, letting users advance repeatedly. Move focus into a slide only when the action explicitly promises navigation to that content.

  • No invisible links remain in the Tab order.
  • Slide changes do not steal focus.
  • Live announcements remain short and user-triggered.
04

Combine swipe, buttons, and motion preferences

Swipe can enhance touch interaction but cannot replace visible buttons. Distinguish a horizontal swipe from vertical page scrolling and avoid hijacking small movements. Mouse drag is optional and should not break text selection inside content-heavy slides.

Use a short transition that indicates direction, then replace it with an immediate state change under reduced motion. Test zoom, keyboard, touch, screen readers, and a slide with long content to ensure the carousel height does not create disruptive page shifts.

Use the pattern

Study it in working components.

These internal examples connect the guide to standalone HTML, CSS, and JavaScript you can preview, customize, and download.