Installation
Add Component
Copy the code snippet below into you components folder.
Integrate Recipe
Integrate this recipe in to your Panda config.
Usage
Shortcuts
IndicatorGroup
The Carousel.IndicatorGroup automatically renders indicators for each page. Instead of:
If you don't need to customize the indicators, you can use the shortcut:
Examples
Multiple
Set the slidesPerPage prop to show multiple items per page.
Auto Play
Set the autoPlay prop to enable automatic sliding.
Images
Here is an example of a carousel displaying images.
Vertical
Set the orientation prop to vertical to create a vertical carousel.
Scroll To
Use the scrollTo method to programmatically navigate to a specific slide.
Props
Root
| Prop | Default | Type | 
|---|---|---|
| slideCount* | numberThe total number of slides. Useful for SSR to render the initial ating the snap points. | |
| size | 'md' | 'md' | 
| allowMouseDrag | false | booleanWhether to allow scrolling via dragging with mouse | 
| autoplay | false | boolean | { delay: number }Whether to scroll automatically. The default delay is 4000ms. | 
| defaultPage | 0 | numberThe initial page to scroll to when rendered. Use when you don't need to control the page of the carousel. | 
| inViewThreshold | 0.6 | number | number[]The threshold for determining if an item is in view. | 
| loop | false | booleanWhether the carousel should loop around. | 
| orientation | \horizontal\ | 'horizontal' | 'vertical'The orientation of the element. | 
| slidesPerMove | \auto\ | number | 'auto'The number of slides to scroll at a time. When set to `auto`, the number of slides to scroll is determined by the `slidesPerPage` property. | 
| slidesPerPage | 1 | numberThe number of slides to show at a time. | 
| snapType | \mandatory\ | 'proximity' | 'mandatory'The snap type of the item. | 
| spacing | \0px\ | stringThe amount of space between items. | 
| inline | boolean | |
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| ids | Partial<{
  root: string
  item: (index: number) => string
  itemGroup: string
  nextTrigger: string
  prevTrigger: string
  indicatorGroup: string
  indicator: (index: number) => string
}>The ids of the elements in the carousel. Useful for composition. | |
| onAutoplayStatusChange | (details: AutoplayStatusDetails) => voidFunction called when the autoplay status changes. | |
| onDragStatusChange | (details: DragStatusDetails) => voidFunction called when the drag status changes. | |
| onPageChange | (details: PageChangeDetails) => voidFunction called when the page changes. | |
| padding | stringDefines the extra space added around the scrollable area, enabling nearby items to remain partially in view. | |
| page | numberThe controlled page of the carousel. | |
| translations | IntlTranslationsThe localized messages to use. | 
Indicator
| Prop | Default | Type | 
|---|---|---|
| index* | numberThe index of the indicator. | |
| readOnly | false | booleanWhether the indicator is read only. | 
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | 
Item
| Prop | Default | Type | 
|---|---|---|
| index* | numberThe index of the item. | |
| snapAlign | \start\ | 'center' | 'end' | 'start'The snap alignment of the item. | 
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. |