Park UI

Carousel

A display component for browsing through multiple items in sequence.

Installation

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

PropDefaultType
slideCount*
number

The total number of slides. Useful for SSR to render the initial ating the snap points.

size'md'
'md'
allowMouseDragfalse
boolean

Whether to allow scrolling via dragging with mouse

autoplayfalse
boolean | { delay: number }

Whether to scroll automatically. The default delay is 4000ms.

defaultPage0
number

The initial page to scroll to when rendered. Use when you don't need to control the page of the carousel.

inViewThreshold0.6
number | number[]

The threshold for determining if an item is in view.

loopfalse
boolean

Whether 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.

slidesPerPage1
number

The number of slides to show at a time.

snapType\mandatory\
'proximity' | 'mandatory'

The snap type of the item.

spacing\0px\
string

The amount of space between items.

inline
boolean
asChild
boolean

Use 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) => void

Function called when the autoplay status changes.

onDragStatusChange
(details: DragStatusDetails) => void

Function called when the drag status changes.

onPageChange
(details: PageChangeDetails) => void

Function called when the page changes.

padding
string

Defines the extra space added around the scrollable area, enabling nearby items to remain partially in view.

page
number

The controlled page of the carousel.

translations
IntlTranslations

The localized messages to use.

Indicator

PropDefaultType
index*
number

The index of the indicator.

readOnlyfalse
boolean

Whether the indicator is read only.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

Item

PropDefaultType
index*
number

The index of the item.

snapAlign\start\
'center' | 'end' | 'start'

The snap alignment of the item.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.