Skip to content

Slideshow

Endless carousel that auto-plays, can be dragged and peeks at the next slide.

From the Nitip template — see it in context
Fishing boats reflected in a still harbourHarbour

Installation

$ npx shadcn@latest add https://framebrick.co/r/slideshow.json

Usage

import { Slideshow } from "@/components/ui/slideshow";

<Slideshow
  items={projects}
  getKey={(p) => p.slug}
  label="Recent work"
  slideClassName="w-[78%] sm:w-[58%]"
  renderItem={(p) => <ProjectCard project={p} />}
/>

Props

PropTypeDefaultDescription
itemsT[]—The slides' data.
renderItem(item, index) => ReactNode—Renders one slide.
getKey(item, index) => string—Stable key per item.
labelstring—Accessible name of the carousel.
intervalnumber5000Milliseconds between slides; 0 turns autoplay off.
gapnumber16Space between slides, in px.
slideClassNamestring—Width of one slide — under 100% the next slide peeks in.
  • Autoplay pauses while the slideshow is hovered, focused, dragged or scrolled out of view.
  • Drag or swipe to move; ← and → move one slide when the carousel has focus.

AI prompt

Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.

Create a React + Tailwind CSS + Motion (motion/react) component called Slideshow — an infinite carousel.
- Render three copies of the items in a flex track; keep an index starting in the middle copy, animate the track's x
  motion value to -index * step with a spring (stiffness 200, damping 40, mass 1), and when the index passes either end,
  jump silently back into the middle copy (x.jump) and reset the index.
- step = slide width + gap, measured with a ResizeObserver on the track.
- Autoplay every `interval` ms, paused while hovered (mouse only), focused, dragged, or out of view (useInView 0.3).
- drag="x" with dragMomentum false; on drag end, advance if the offset is over 20% of a slide or the velocity over 500,
  otherwise spring back.
- Arrow buttons bottom-right: size-8 rounded-full border bg-background/80 shadow-sm.
- Accessibility: role region, aria-roledescription carousel, aria-label, tabIndex 0 with ArrowLeft/ArrowRight,
  aria-hidden on slides that are not current.

Be the first to know

Get new templates and components first

One short email when we release a template or a free component. No spam — unsubscribe anytime.

We use your email only for Framebrick updates. Privacy policy