Image Carousel

MediumImage CarouselReact25 mins

by Pratik Rai

Read the full write-up

Build an image carousel that shows one image at a time from a fixed list, with arrows to step through them and a row of dots showing where you are.

The images and the styling are already in the starter. What is missing is the behaviour.

Requirements

  1. Show one image at a time, starting with the first.

  2. The and arrows move back and forward by one image.

  3. Both arrows wrap around: forward from the last image lands on the first, back from the first lands on the last.

  4. Render one dot per image, and mark the dot for the image on screen so it is distinguishable from the rest.

  5. Clicking a dot jumps straight to that image.

  6. Every control is a real <button> with an accessible name, so the carousel works from the keyboard.

Notes

  • The focus is behaviour, not visual polish — styles.css already covers the layout, and .dot-active is waiting for you.

  • No data fetching and no libraries: the images are defined in App.js, and the preview only has React available.

  • Sliding animations, autoplay and swipe are out of scope. They are the natural follow-ups once this works.

Hints

Loading editor…