Image Slider
Full-bleed image slider with crossfade-zoom, autoplay, dots, arrows and swipe.
- 3.0 KB gzipped
- Deps: motion/react
- Reduced-motion safe
- Base UI & Radix compatible
Installation
pnpm dlx shadcn@latest add https://velora.colorlib.com/r/image-slider.jsonAdds components/velora/image-slider.tsx, installs motion.
Examples
Hero
A landing hero with a headline and call-to-action layered over an autoplaying slider.
Spring collection · 42 new listings
Homes built around the light
Architect-designed houses with open plans, big glass and quiet gardens, ready to move into this season.
Props
| Prop | Type | Default |
|---|---|---|
images*Images to cycle through | SliderImage[] | — |
childrenContent layered above the images (headline, call-to-action…) | React.ReactNode | — |
autoplayAdvance automatically (never starts on its own under reduced motion) | boolean | true |
intervalms each slide stays on screen while autoplaying | number | 5000 |
scrimDarken the images so overlay text and controls stay legible | boolean | true |
labelAccessible name for the carousel region | string | "Image slider" |
Also accepts every React.HTMLAttributes<HTMLElement> prop, forwarded to the root element.
SliderImage
interface SliderImage {
/** Image URL */
src: string;
/** Alternative text ("" when the image is purely decorative) */
alt: string;
}Accessibility
- Reduced motion
- Autoplay never starts on its own and slides change instantly with no fade or zoom; pressing Play opts in to autoplay with instant changes.
- Keyboard
- Previous, next, pause/play and dot buttons are native buttons; Left/Right arrows (and Home/End) change slides while focus is inside the slider. Autoplay pauses while hovered or while focus is inside.
- Screen readers
- A region with aria-roledescription="carousel" whose current slide is a group labelled "n of N"; image alt text is read, and slide changes are announced politely only while autoplay is not running.