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.
autoSizeboolean
false
Whether the carousel should auto size.
orientation"horizontal" | "vertical"
'horizontal'
Orientation of the carousel.
align"center" | "start" | "end"
'center'
Alignment of the carousel items.
loopboolean
false
Whether the carousel should loop.
snapType"mandatory" | "proximity"
'mandatory'
Scroll snap type applied to the track.
spacingnumber
16
Spacing between carousel items.
slidesPerPagenumber
1
How many slides are visible per page. Supports fractions (e.g. 1.5).
pagenumber
undefined
Index of the active slide.
slidenumber
undefined
Index of the active slide.
defaultPagenumber
0
Default index of the active slide.
onPageChange(event: useCarouselChangeEvent) => void
null
Callback fired when the carousel's page changes.
onSlideChange(event: useCarouselChangeEvent) => void
null
Callback fired when the active slide (by value) 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
isPrevDisabledboolean
null
Whether the "previous" navigation button should be disabled.
isNextDisabledboolean
null
Whether the "next" navigation button should be disabled.
snapPointsSet<number>
null
The snap points of the carousel.
pagenumber
null
The current page of the carousel.
swipingboolean
null
Whether the user is currently swiping the carousel by touch.

Exposes#

Defines the methods and properties exposed by Carousel component.

nametypedefaultdescription
stateuseCarouselState
null
The state of the useCarousel.
contentStylesCSSProperties
null
Styles applied to the content element.
itemStylesCSSProperties
null
Styles applied to the item elements.
contentRefRefObject<HTMLDivElement>
null
Ref to the content element.
prev() => void
null
Navigates to the previous slide.
next() => void
null
Navigates to the next slide.
scrollTo(value: number) => void
null
Scrolls to the specified value.
scrollToPage(page: number) => void
null
Scrolls to the specified page.
scrollToSlide(slide: number) => void
null
Scrolls to the specified slide value.
setToClosest() => void
null
Scrolls to the closest snap point.
onContentPointerDown(event: PointerEvent<HTMLDivElement>) => void
null
Event handler for content pointer down.
onContentPointerMove(event: PointerEvent<HTMLDivElement>) => void
null
Event handler for content pointer move.
onContentPointerUp(event: PointerEvent<HTMLDivElement>) => void
null
Event handler for content pointer up.
onContentWheel(event: WheelEvent<HTMLDivElement>) => void
null
Event handler for content wheel.

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.
[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
autoSizeboolean
false
Whether the carousel should auto size.
orientation"horizontal" | "vertical"
'horizontal'
Orientation of the carousel.
align"center" | "start" | "end"
'center'
Alignment of the carousel items.
loopboolean
false
Whether the carousel should loop.
snapType"mandatory" | "proximity"
'mandatory'
Scroll snap type applied to the track.
spacingnumber
16
Spacing between carousel items.
slidesPerPagenumber
1
How many slides are visible per page. Supports fractions (e.g. 1.5).
pagenumber
undefined
Index of the active slide.
slidenumber
undefined
Index of the active slide.
defaultPagenumber
0
Default index of the active slide.
onPageChange(event: useCarouselChangeEvent) => void
null
Callback fired when the carousel's page changes.
onSlideChange(event: useCarouselChangeEvent) => void
null
Callback fired when the active slide (by value) changes.

State#

Defines valid state in useCarousel.

nametypedefaultdescription
isPrevDisabledboolean
null
Whether the "previous" navigation button should be disabled.
isNextDisabledboolean
null
Whether the "next" navigation button should be disabled.
snapPointsSet<number>
null
The snap points of the carousel.
pagenumber
null
The current page of the carousel.
swipingboolean
null
Whether the user is currently swiping the carousel by touch.

Exposes#

Defines the methods and properties exposed by useCarousel.

nametypedefaultdescription
stateuseCarouselState
null
The state of the useCarousel.
contentStylesCSSProperties
null
Styles applied to the content element.
itemStylesCSSProperties
null
Styles applied to the item elements.
contentRefRefObject<HTMLDivElement>
null
Ref to the content element.
prev() => void
null
Navigates to the previous slide.
next() => void
null
Navigates to the next slide.
scrollTo(value: number) => void
null
Scrolls to the specified value.
scrollToPage(page: number) => void
null
Scrolls to the specified page.
scrollToSlide(slide: number) => void
null
Scrolls to the specified slide value.
setToClosest() => void
null
Scrolls to the closest snap point.
onContentPointerDown(event: PointerEvent<HTMLDivElement>) => void
null
Event handler for content pointer down.
onContentPointerMove(event: PointerEvent<HTMLDivElement>) => void
null
Event handler for content pointer move.
onContentPointerUp(event: PointerEvent<HTMLDivElement>) => void
null
Event handler for content pointer up.
onContentWheel(event: WheelEvent<HTMLDivElement>) => void
null
Event handler for content wheel.

Interfaces#

Types#

Instance of useCarousel headless.

values
HeadlessInstance<useCarouselProps, useCarouselState, useCarouselExposes>