Carousel API

API documentation for Carousel component

Props#

Defines valid properties in Carousel component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CarouselInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CarouselInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CarouselPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CarouselInstance) => ReactNode)
null
The children to render.
orientation"horizontal" | "vertical"
'horizontal'
Orientation of the carousel.
align"center" | "start" | "end"
'start'
Alignment of the carousel items.
loopboolean
false
Whether the carousel should loop.
spacingnumber
16
Spacing between carousel items.
slidenumber
0
Index of the active slide.
onSlideChange(event: useCarouselChangeEvent) => void
null
Callback fired when the carousel's slide changes.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Defines valid state in Carousel component.

nametypedefaultdescription
scrollSnapsnumber[]
null
Array of calculated scroll positions (snap points) for each slide.
snapPointsnumber[]
null
Array of calculated scroll positions (snap points) for each slide.
isSwipingboolean
null
Indicates whether the user is currently swiping/dragging the carousel.
slideSizesnumber[]
null
Array of sizes (width or height depending on orientation) of each slide.
canLoopboolean
null
Indicates if looping (circular scroll) is enabled or possible.
snapsnumber[]
null
Array of raw snap offsets without adjustments for looping or alignment.
activeIndexnumber
null
The index of the currently active slide.
prevDisabledboolean
null
Whether the "previous" navigation button should be disabled.
nextDisabledboolean
null
Whether the "next" navigation button should be disabled.

Exposes#

Defines the methods and properties exposed by Carousel component.

nametypedefaultdescription
stateuseCarouselState
null
The state of the useCarousel.
carouselRefRefObject<HTMLDivElement>
null
Ref to the main carousel container DOM element.
addSlideRef(el: HTMLDivElement) => void
null
Adds a reference to a slide element.
slideTo(index?: number, offset?: number) => void
null
Scrolls the carousel to a specific slide index.
handlePointerUp(event: PointerEvent) => void
null
Handles pointer release events.
handlePointerDown(event: PointerEvent) => void
null
Handles pointer down events.
handlePointerMove(event: PointerEvent) => void
null
Handles pointer move events.
handlePrev() => void
null
Handles previous button click events.
handleNext() => void
null
Handles next button click events.
handleClick(event: MouseEvent) => void
null
Handles carousel container click events.

Interfaces#

Defines passthrough(pt) options of Carousel component.

nametypedefaultdescription
rootCarouselPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of Carousel component.

values
ComponentInstance<CarouselProps, CarouselState, CarouselExposes>

CarouselContent#

Props#

Defines valid properties in CarouselContent component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CarouselContentInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CarouselContentInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CarouselContentPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CarouselContentInstance) => ReactNode)
null
The children to render.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Exposes#

Defines the methods and properties exposed by CarouselContent component.

nametypedefaultdescription
carouselCarouselInstance
null
The Carousel component instance.

Interfaces#

Defines passthrough(pt) options of CarouselContent component.

nametypedefaultdescription
rootCarouselContentPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of CarouselContent component.

values
ComponentInstance<CarouselContentProps, CarouselContentState, CarouselContentExposes>

CarouselItem#

Props#

Defines valid properties in CarouselItem component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CarouselItemInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CarouselItemInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CarouselItemPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CarouselItemInstance) => ReactNode)
null
The children to render.
sizenumber
null
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Exposes#

Defines the methods and properties exposed by CarouselItem component.

nametypedefaultdescription
carouselCarouselInstance
null
The Carousel component instance.

Interfaces#

Defines passthrough(pt) options of CarouselItem component.

nametypedefaultdescription
rootCarouselItemPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of CarouselItem component.

values
ComponentInstance<CarouselItemProps, CarouselItemState, CarouselItemExposes>

CarouselIndicators#

Props#

Defines valid properties in CarouselIndicators component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CarouselIndicatorsInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CarouselIndicatorsInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CarouselIndicatorsPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CarouselIndicatorsInstance) => ReactNode)
null
The children to render.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Exposes#

Defines the methods and properties exposed by CarouselIndicators component.

nametypedefaultdescription
carouselCarouselInstance
null
The Carousel component instance.

Interfaces#

Defines passthrough(pt) options of CarouselIndicators component.

nametypedefaultdescription
rootCarouselIndicatorsPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of CarouselIndicators component.

values
ComponentInstance<CarouselIndicatorsProps, CarouselIndicatorsState, CarouselIndicatorsExposes>

CarouselIndicator#

Props#

Defines valid properties in CarouselIndicator component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CarouselIndicatorInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CarouselIndicatorInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CarouselIndicatorPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CarouselIndicatorInstance) => ReactNode)
null
The children to render.
snapnumber
null
indexnumber
null
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Exposes#

Defines the methods and properties exposed by CarouselIndicator component.

nametypedefaultdescription
carouselCarouselInstance
null
The Carousel component instance.

Interfaces#

Defines passthrough(pt) options of CarouselIndicator component.

nametypedefaultdescription
rootCarouselIndicatorPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of CarouselIndicator component.

values
ComponentInstance<CarouselIndicatorProps, CarouselIndicatorState, CarouselIndicatorExposes>

CarouselNext#

Props#

Defines valid properties in CarouselNext component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CarouselNextInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CarouselNextInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CarouselNextPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CarouselNextInstance) => ReactNode)
null
The children to render.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Exposes#

Defines the methods and properties exposed by CarouselNext component.

nametypedefaultdescription
carouselCarouselInstance
null
The Carousel component instance.

Interfaces#

Defines passthrough(pt) options of CarouselNext component.

nametypedefaultdescription
rootCarouselNextPassThroughType<HTMLAttributes<HTMLButtonElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of CarouselNext component.

values
ComponentInstance<CarouselNextProps, CarouselNextState, CarouselNextExposes>

CarouselPrev#

Props#

Defines valid properties in CarouselPrev component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CarouselPrevInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CarouselPrevInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CarouselPrevPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CarouselPrevInstance) => ReactNode)
null
The children to render.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Exposes#

Defines the methods and properties exposed by CarouselPrev component.

nametypedefaultdescription
carouselCarouselInstance
null
The Carousel component instance.

Interfaces#

Defines passthrough(pt) options of CarouselPrev component.

nametypedefaultdescription
rootCarouselPrevPassThroughType<HTMLAttributes<HTMLButtonElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of CarouselPrev component.

values
ComponentInstance<CarouselPrevProps, CarouselPrevState, CarouselPrevExposes>

useCarousel#

Props#

Defines valid properties in useCarousel.

nametypedefaultdescription
orientation"horizontal" | "vertical"
'horizontal'
Orientation of the carousel.
align"center" | "start" | "end"
'start'
Alignment of the carousel items.
loopboolean
false
Whether the carousel should loop.
spacingnumber
16
Spacing between carousel items.
slidenumber
0
Index of the active slide.
onSlideChange(event: useCarouselChangeEvent) => void
null
Callback fired when the carousel's slide changes.

State#

Defines valid state in useCarousel.

nametypedefaultdescription
scrollSnapsnumber[]
null
Array of calculated scroll positions (snap points) for each slide.
snapPointsnumber[]
null
Array of calculated scroll positions (snap points) for each slide.
isSwipingboolean
null
Indicates whether the user is currently swiping/dragging the carousel.
slideSizesnumber[]
null
Array of sizes (width or height depending on orientation) of each slide.
canLoopboolean
null
Indicates if looping (circular scroll) is enabled or possible.
snapsnumber[]
null
Array of raw snap offsets without adjustments for looping or alignment.
activeIndexnumber
null
The index of the currently active slide.
prevDisabledboolean
null
Whether the "previous" navigation button should be disabled.
nextDisabledboolean
null
Whether the "next" navigation button should be disabled.

Exposes#

Defines the methods and properties exposed by useCarousel.

nametypedefaultdescription
stateuseCarouselState
null
The state of the useCarousel.
carouselRefRefObject<HTMLDivElement>
null
Ref to the main carousel container DOM element.
addSlideRef(el: HTMLDivElement) => void
null
Adds a reference to a slide element.
slideTo(index?: number, offset?: number) => void
null
Scrolls the carousel to a specific slide index.
handlePointerUp(event: PointerEvent) => void
null
Handles pointer release events.
handlePointerDown(event: PointerEvent) => void
null
Handles pointer down events.
handlePointerMove(event: PointerEvent) => void
null
Handles pointer move events.
handlePrev() => void
null
Handles previous button click events.
handleNext() => void
null
Handles next button click events.
handleClick(event: MouseEvent) => void
null
Handles carousel container click events.

Interfaces#

Types#

Instance of useCarousel headless.

values
HeadlessInstance<useCarouselProps, useCarouselState, useCarouselExposes>