Carousel
Scrollable content slides with previous and next controls.
Installation
Add the component and its dependencies from the registry running on your computer.
npx shadcn@latest add https://brutallab.facilito.dev/r/carousel.jsonUsage
Import the component into your project and keep the source code under your control.
'use client';
import {
Carousel,
CarouselContent,
CarouselItem,
CarouselPrevious,
CarouselNext,
} from '@/components/ui/carousel';
export default function Demo() {
return (
<Carousel
className="mx-12 w-[calc(100%-6rem)] max-w-sm"
aria-label="Component highlights"
>
<CarouselContent>
{['Build', 'Customize', 'Ship'].map((title, index) => (
<CarouselItem key={title}>
<div className="grid min-h-48 place-content-center gap-3 rounded-lg border-2 border-ink bg-card text-card-foreground p-6 text-center">
<p className="bl-type-eyebrow">0{index + 1}</p>
<h3 className="bl-type-section-title">{title}</h3>
</div>
</CarouselItem>
))}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
</Carousel>
);
}
States & interaction
Appearance, behavior and keyboard checks.
- The composition inherits its controls’ states. Test empty, content, loading and error cases where the application needs them.
- Examples on this page are runnable; the displayed code uses the same components. Business logic belongs to the consumer.
- Test the example with Tab and Shift+Tab. Focus must stay visible in both themes.
API Reference
BrutalLab-specific properties. Native attributes are supported as well.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | horizontal / vertical | horizontal | Scrolling axis. |
| opts | EmblaOptionsType | — | Options passed to Embla. |
Accessibility
Rules that should remain intact when adapting the component to a product.
Name the carousel and retain visible navigation controls. This demo never auto-advances.
Retain keyboard focus styles and test the composition with keyboard navigation.
Use className for visual customization; preserve the primitive ARIA attributes.
Arrow keys match orientation and RTL direction; nested controls retain their own keys. Reduced motion jumps without animation.