Accessible carousel
A keyboard-navigable, screen-reader–friendly carousel built with native HTML and Tailwind CSS. No JavaScript framework required.
Ingredients
- Semantic
<section>witharia-roledescription="carousel" aria-labelon each slide for screen readers- Tab-indexed navigation buttons with
aria-controls - CSS
scroll-snap-typefor smooth native scrolling prefers-reduced-motionguard for vestibular safety- Live region announcement of current slide index
Steps
- Wrap slides in a scroll container with
overflow-x-auto snap-x snap-mandatory. - Each slide gets
snap-center shrink-0 w-fulland a uniqueid. - Add prev/next buttons that call
scrollByon the container. - Wire
aria-controlson buttons to the containerid. - Track visible slide via
IntersectionObserverand update a live region. - Disable transitions when
prefers-reduced-motionis active. - Ensure all interactive elements are reachable via Tab and operable with Enter / Space.
Accessibility checklist
- ✓ WCAG 2.2 AA compliant when implemented correctly
- ✓ Works with VoiceOver, NVDA, and JAWS
- ✓ No focus traps — users can exit the carousel freely
- ✓ Respects OS motion reduction preferences