Back to elements
ElementData DisplayFree

Basic Carousel React component

A plain, dependable carousel: drag or swipe between slides, arrows and dots, one to four slides in view, looping, and optional autoplay whose progress fills the active dot and pauses whenever someone hovers, focuses or drags.

When to use the Basic Carousel component

Use Basic Carousel when a handful of items should share one spot on the page: hero images, featured products, testimonials or photo sets. It's deliberately plain, so it fits anywhere without drawing attention away from the content.

Keep autoplay for decorative images; for content people need to read or compare, leave it off and let them drag or use the arrows.

Installation

Add the Basic Carousel component to your project with the shadcn CLI. It lands in components/basic-carousel.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add https://reactframe.com/r/basic-carousel.json

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

Props

<BasicCarousel /> accepts 16 props, all optional.

  • slides

    Image slides. Pass children instead for your own slide content.

    { src: string; alt: string; title?: string; description?: string }[]
    Default: DEFAULT_SLIDES
  • children
    React.ReactNode
  • slidesPerView

    How many slides show at once (1–4).

    number
    Default: 1
  • gap

    Space between slides, in px.

    number
    Default: 12
  • loop

    After the last slide, go back to the first (and the other way).

    boolean
    Default: true
  • autoplay

    Move on by itself; pauses while hovered, focused, dragged or off-screen.

    boolean
    Default: false
  • interval

    Milliseconds per slide when autoplaying.

    number
    Default: 4000
  • showArrows
    boolean
    Default: true
  • showDots
    boolean
    Default: true
  • aspectRatio

    Slide shape, e.g. "16 / 10" or "1 / 1".

    string
    Default: "16 / 10"
  • index
    number
  • defaultIndex
    number
    Default: 0
Show all 16 props
  • onIndexChange
    (index: number) => void
  • label

    Accessible name for the carousel.

    string
    Default: "Carousel"
  • theme
    "dark" | "light"
    Default: "dark"
  • className
    string

FAQ

Can it show several slides at once?
Yes. slidesPerView shows one to four; arrows, dots and dragging then move one slide at a time and stop at the last full view unless loop is on.
When does autoplay stop?
It pauses while the carousel is hovered, focused or being dragged, and while the browser tab is hidden. The active dot fills up to show time until the next slide.
Can I put my own content in the slides?
Pass children instead of slides; each child becomes a slide with the same sizing, dragging and controls.

Related components

Sparkline Stat
Free
Calendar
Free
Checklist
Free
Icon List
Free
Tag Input
Free
Empty State
Free