Carousel
Horizontally scrolling set of slides with previous and next controls.
Installation
bun add @xerobi/ui
import { ArrowButton, Carousel, CarouselArrowBasicButtons, CarouselArrowFloatButtons, CarouselArrowNumberButtons, CarouselDotButtons, CarouselProgressBar, CarouselSlide, CarouselThumb, CarouselThumbs } from "@xerobi/ui/carousel"This component is client-side. In Astro, hydrate it with a client directive.
API reference
ArrowButton
| Prop | Type | Description |
|---|---|---|
| svgSize | number | |
| variant* | "prev" | "next" | |
| svgIcon | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| options | { direction?: AxisDirectionOptionType | undefined; axis?: AxisOptionType | undefined; } |
Carousel
| Prop | Type | Description |
|---|---|---|
| carousel* | { pluginNames?: string[] | undefined; options?: CarouselOptions | undefined; mainRef: EmblaViewportRefType; mainApi?: EmblaCarouselType | undefined; thumbs: ... | |
| slotProps | { container?: string | undefined; slide?: string | undefined; } |
CarouselArrowBasicButtons
| Prop | Type | Description |
|---|---|---|
| disablePrev* | boolean | |
| disableNext* | boolean | |
| onClickPrev* | () => void | |
| onClickNext* | () => void | |
| totalSlides | number | |
| selectedIndex | number | |
| options | { align?: AlignmentOptionType | undefined; axis?: AxisOptionType | undefined; container?: string | HTMLElement | null | undefined; slides?: string | HTMLElem... | |
| slotProps | { prevBtn?: ArrowSlot | undefined; nextBtn?: ArrowSlot | undefined; } |
CarouselArrowFloatButtons
| Prop | Type | Description |
|---|---|---|
| disablePrev* | boolean | |
| disableNext* | boolean | |
| onClickPrev* | () => void | |
| onClickNext* | () => void | |
| totalSlides | number | |
| selectedIndex | number | |
| options | { align?: AlignmentOptionType | undefined; axis?: AxisOptionType | undefined; container?: string | HTMLElement | null | undefined; slides?: string | HTMLElem... | |
| slotProps | { prevBtn?: ArrowSlot | undefined; nextBtn?: ArrowSlot | undefined; } |
CarouselArrowNumberButtons
| Prop | Type | Description |
|---|---|---|
| disablePrev* | boolean | |
| disableNext* | boolean | |
| onClickPrev* | () => void | |
| onClickNext* | () => void | |
| totalSlides | number | |
| selectedIndex | number | |
| options | { align?: AlignmentOptionType | undefined; axis?: AxisOptionType | undefined; container?: string | HTMLElement | null | undefined; slides?: string | HTMLElem... | |
| slotProps | { prevBtn?: ArrowSlot | undefined; nextBtn?: ArrowSlot | undefined; } |
CarouselDotButtons
| Prop | Type | Description |
|---|---|---|
| selectedIndex* | number | |
| scrollSnaps* | number[] | |
| onClickDot* | (index: number) => void | |
| gap | number | |
| variant | "number" | "circular" | "rounded" | |
| slotProps | { dot?: { size?: number | undefined; className?: string | undefined; style?: CSSProperties | undefined; } | undefined; } |
CarouselProgressBar
| Prop | Type | Description |
|---|---|---|
| value* | number |
CarouselSlide
| Prop | Type | Description |
|---|---|---|
| options | { align?: AlignmentOptionType | undefined; axis?: AxisOptionType | undefined; container?: string | HTMLElement | null | undefined; slides?: string | HTMLElem... |
CarouselThumb
| Prop | Type | Description |
|---|---|---|
| src* | string | |
| index* | number | |
| selected* | boolean |
CarouselThumbs
| Prop | Type | Description |
|---|---|---|
| options | { align?: AlignmentOptionType | undefined; axis?: AxisOptionType | undefined; container?: string | HTMLElement | null | undefined; slides?: string | HTMLElem... | |
| slotProps | { slide?: string | undefined; container?: string | undefined; disableMask?: boolean | undefined; } |
Hooks
useCarouseluseCarouselArrowsuseCarouselAutoPlayuseCarouselAutoScrolluseCarouselDotsuseCarouselProgressuseThumbs