Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Hero Slider

ProNew

Full-width hero slides with photo, video or colour backgrounds, headline, text and CTA, with arrows, four pagination styles, a progress bar and autoplay.

Installation

pnpm dlx shadcn@latest add @viewport/hero-slider

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
slides*HeroSlide[]—
transition"slide" | "fade" | "zoom"

How one slide replaces the next.

"slide"
durationnumber

Length of the transition, in seconds.

0.6
autoplayboolean

Advance on a timer. Never runs under reduced motion.

true
intervalnumber

Seconds each slide stays up while autoplay runs.

6
loopboolean

Wrap around from the last slide to the first.

true
arrowsboolean

Show the previous and next arrows.

true
mobileArrowsboolean

Keep arrows available on narrow screens instead of hiding them.

false
arrowPreviewboolean

Preview the neighbouring slide on arrow hover or keyboard focus.

false
pagination"strokes" | "bullets" | "numbers" | "thumbnails" | "none"

The style of the page indicator.

"strokes"
progressboolean

Show a bar across the top that fills while a slide is up.

true
kenBurnsboolean

Slowly zoom the background while a slide is up.

false
radiusnumber

Corner radius of the slider, in pixels.

16
minHeightnumber

Shortest height of a slide on wide screens, in pixels. Slides grow to fit their text.

440
mobileMinHeightnumber

Shortest height on narrow screens; without it, use 72% of `minHeight`.

—
labelstring

Names the slider for screen readers.

"Featured"
onSlideChange(index: number) => void

Called with the new index after every change.

—
classNamestring—

Accessibility

  • A labelled carousel: each slide is a group named “2 of 4”, and arrows, dots and thumbnails are named buttons.
  • Autoplay pauses on hover, on keyboard focus and in a background tab, and has its own pause button.
  • Left and Right change slide from anywhere inside; swipe works on touch screens.
  • Slide changes are announced only when you make them, not while autoplay runs.
  • Under reduced motion autoplay, the zoom and video playback stay off and slides swap with a short fade.