Skip to Content
archive
Components

Carousel

A large image viewer with an optional thumbnail list, hover arrows, a position counter, drag or click navigation, and a fullscreen view.

Carousel shows one large image at a time. Use the position prop to place a thumbnail list beside the image, or leave it out to show the image alone.

  • Hover over the image to show the < and > buttons, or drag the image left or right.
  • Click a thumbnail to jump to that image.
  • The counter in the bottom-right shows the current position.
  • Click the fullscreen button to view the current image over a dark backdrop. Use < and > (or the arrow keys) to move between images, and click anywhere or press Escape to close.

Installation

bunx --bun shadcn@latest add https://docs.danpoj.site/r/carousel.json

Running the command above installs the carousel component along with its dependencies: the shadcn button component (used for the arrow and fullscreen buttons) and the motion package (used for the spring animation and the fullscreen view).

Examples

Thumbnails on the left

1 / 9

Thumbnails on the right

1 / 9

Thumbnails on the top

1 / 9

Thumbnails on the bottom

1 / 9

Without thumbnails

When position is not passed, the carousel shows only the large image, the arrows, and the counter.

1 / 9

Props

PropTypeDefaultDescription
imagesstring[]-The image URLs to show, in order. Renders nothing when the array is empty.
position'left' | 'right' | 'top' | 'bottom' | nullnullWhere the thumbnail list is placed relative to the large image. null hides the thumbnail list.
speednumber25Speed of the slide animation. Higher values move faster and settle sooner.
classNamestring-Extra classes merged with the root element. Use it to set the width, for example max-w-xl.

Last updated on

On this page