Components
Carousel
NativeSlides in a row that scroll sideways and snap into place.
Installation
npx nook-ui@latest add carouselPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Carousel" component to this project, exactly as Nook ships it.
Slides in a row that scroll sideways and snap into place.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add carousel`. It writes `components/ui/carousel.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/carousel.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { Carousel, CarouselItem } from "@/components/ui/carousel";
const STORIES = [
{ quote: "We replaced three tools and our weekly planning takes half the time.", name: "Maya Chen", role: "Design lead, Nook" },
{ quote: "Reports that the whole team can read without asking me what they mean.", name: "Arif Rahman", role: "Engineering manager, Northwind" },
{ quote: "Setup took an afternoon. We have not touched the config since.", name: "Lena Fischer", role: "Founder, Globex" },
{ quote: "Support answers within the hour, every time.", name: "Sam Okafor", role: "Operations, Initech" },
];
export default function CarouselDefault() {
return (
<Carousel aria-label="Customer stories">
{STORIES.map((story) => (
<CarouselItem key={story.name} className="sm:basis-[calc(50%-0.5rem)]">
<figure className="flex h-full flex-col justify-between gap-6 rounded-lg border-(length:--edge) border-(--field-edge) bg-card p-5">
<blockquote className="text-base leading-relaxed text-pretty">{story.quote}</blockquote>
<figcaption className="text-sm">
<span className="font-medium">{story.name}</span>
<span className="block text-muted-foreground">{story.role}</span>
</figcaption>
</figure>
</CarouselItem>
))}
</Carousel>
);
}
```
API
- `Carousel`: The row and its controls.
- `aria-label` (`string`): Names the carousel.
- `hideDots` (`boolean`): Hide the row of dots.
- `CarouselItem`: One slide. Set a width such as `basis-1/2` to show several at once.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: A named region of slides, each announced with its position. Swipe, use the buttons, the dots or the arrow keys. It never moves by itself.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { Carousel, CarouselItem } from "@/components/ui/carousel";
const STORIES = [
{ quote: "We replaced three tools and our weekly planning takes half the time.", name: "Maya Chen", role: "Design lead, Nook" },
{ quote: "Reports that the whole team can read without asking me what they mean.", name: "Arif Rahman", role: "Engineering manager, Northwind" },
{ quote: "Setup took an afternoon. We have not touched the config since.", name: "Lena Fischer", role: "Founder, Globex" },
{ quote: "Support answers within the hour, every time.", name: "Sam Okafor", role: "Operations, Initech" },
];
export default function CarouselDefault() {
return (
<Carousel aria-label="Customer stories">
{STORIES.map((story) => (
<CarouselItem key={story.name} className="sm:basis-[calc(50%-0.5rem)]">
<figure className="flex h-full flex-col justify-between gap-6 rounded-lg border-(length:--edge) border-(--field-edge) bg-card p-5">
<blockquote className="text-base leading-relaxed text-pretty">{story.quote}</blockquote>
<figcaption className="text-sm">
<span className="font-medium">{story.name}</span>
<span className="block text-muted-foreground">{story.role}</span>
</figcaption>
</figure>
</CarouselItem>
))}
</Carousel>
);
}Examples
Product row
Tips without dots
Long testimonials
Props
Carousel
The row and its controls.
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-label | string | – | Names the carousel. |
| hideDots | boolean | – | Hide the row of dots. |
CarouselItem
One slide. Set a width such as `basis-1/2` to show several at once.
Accessibility
A named region of slides, each announced with its position. Swipe, use the buttons, the dots or the arrow keys. It never moves by itself.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.