FlashcardNot attempted
Design an image carousel / gallery
Recall it before you reveal
What would you cover when designing a reusable image carousel component?
Space to reveal
Show answer & explanation
- API:
items,renderItem,autoPlay,interval,loop,onChange, controlled vs uncontrolledindex. - Performance: lazy-load off-screen images and preload neighbours;
srcset/sizes; animate withtransform(GPU); avoid layout shift with an aspect-ratio box. - Input: buttons, dots, swipe (pointer events), keyboard arrows.
- A11y:
aria-roledescription="carousel", a label for each slide ("3 of 8"), pause autoplay on hover/focus and provide a pause button (WCAG 2.2.2), respect reduced motion. - Edge cases: a single item, items changing while open, RTL.