Carousel
A carousel with motion and swipe built using a tiny island.
Carousel — slider horizontal ou vertical. Chaque CarouselItem est un slide, snap sur le scroll. Boutons Previous/Next pour navigation, plus le scroll natif (drag/wheel) et le swipe tactile.
Installation
$ bext ui add carousel
Copy and paste the following into src/components/ui/carousel.tsx.
This component is interactive — make sure the shared island is loaded (see Islands). It reacts to data-ui="carousel" hooks.
Usage
Anatomy
<Carousel> ├── <CarouselContent> │ ├── <CarouselItem>slide 1</CarouselItem> │ ├── <CarouselItem>slide 2</CarouselItem> │ └── <CarouselItem>slide 3</CarouselItem> ├── <CarouselPrevious /> └── <CarouselNext /> </Carousel>
API Reference
Carousel
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | undefined |
| children | ReactNode | — | undefined |
CarouselContent
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | undefined |
CarouselItem
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Un slide. Par défaut basis-full. Pour multi-slide visible : basis-1/2 md:basis-1/3 … |
CarouselPrevious / CarouselNext
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | undefined |
Data Attributes
Attributs qu'on peut cibler en CSS custom pour override le style par état.
| Attribute | On | Values | Description |
|---|---|---|---|
| data-ui="carousel" | Carousel root | undefined | undefined |
| data-orientation | Carousel root | "horizontal" | "vertical" | undefined |
Keyboard
| Key | Action |
|---|---|
| Arrow Left / Right | Slide précédent / suivant. |
| Home / End | Premier / dernier slide. |
Accessibility
role="region" aria-roledescription="carousel". Chaque slide porte role="group" aria-roledescription="slide" aria-label="N of M".
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
On This Page