Carousel
Discrete slide stepping, a dot per slide, arrow keys
Workspace previews
Slide 1 of 4 · wraps at both ends
Installation
npx shadcn@latest add @sudokw/components-carouselimport { Carousel } from "@gpuixui/components";Usage
import {
Carousel,
CarouselControl,
CarouselIndicators,
CarouselSlide,
CarouselTrack,
} from "@gpuixui/components";
import { useState } from "react";
export const WorkspacePreviews = () => {
const [index, setIndex] = useState(0);
return (
<Carousel label="Workspace previews" onValueChange={setIndex} value={index}>
<CarouselTrack>
<CarouselSlide>Overview</CarouselSlide>
<CarouselSlide>Activity</CarouselSlide>
<CarouselSlide>Members</CarouselSlide>
</CarouselTrack>
<CarouselControl direction="previous" />
<CarouselControl direction="next" />
<CarouselIndicators />
</Carousel>
);
};Composition
Carousel
├── CarouselTrack
│ └── CarouselSlide
├── CarouselControl
└── CarouselIndicatorsAPI reference
Carousel
| Prop | Type | Default | Consequence |
|---|---|---|---|
label | string | — | the region's accessible name; required |
value | number | — | controlled slide index |
defaultValue | number | 0 | the opening slide when uncontrolled |
onValueChange | (value: number) => void | none | the next index |
loop | boolean | false | wraps past both ends and keeps both controls live |
className | string | — | joined last |
children | ReactNode | none | the track and the controls, directly inside |
CarouselTrack
| Prop | Type | Default | Consequence |
|---|---|---|---|
children | ReactNode | none | the slides, as direct children |
className | string | — | joined last |
CarouselSlide
| Prop | Type | Default | Consequence |
|---|---|---|---|
children | ReactNode | none | the slide's content |
style | StateStyle<CarouselSlideState> | — | { active, index }, merged last |
className | string | — | joined last |
CarouselControl
| Prop | Type | Default | Consequence |
|---|---|---|---|
direction | "previous" | "next" | — | which way it steps; required |
label | string | "Previous slide" / "Next slide" | the accessible name |
disabled | boolean | false | adds to the edge rule; never removes it |
CarouselIndicators
| Prop | Type | Default | Consequence |
|---|---|---|---|
label | string | "Choose a slide" | the dot group's accessible name |
style | StateStyle<CarouselIndicatorsState> | — | { active, count }, merged last |
className | string | — | joined last |
Keyboard
- Arrow RightArrow Left
- steps one slide
- HomeEnd
- the first or last slide
- EnterSpace
- chooses the focused dot
read from carousel.tsx
Edit this page on GitHubapps/docs/content/docs/components/carousel.mdx