Xzero UI
Pro library

Carousel

Browse a row of slides by dragging, flicking, or arrowing through them.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/carousel
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/carousel

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { Carousel } from "@/components/xzero/carousel/carousel";

export function Suites() {
  return (
    <Carousel label="Harbour suites" interval={5000}>
      <img src="/suite-1.jpg" alt="Sea view suite" />
      <img src="/suite-2.jpg" alt="Garden suite" />
      <img src="/suite-3.jpg" alt="Loft suite" />
    </Carousel>
  );
}

API reference

Carousel

A centered slide row browsed by drag, flick, trackpad swipe, arrow keys, or pill indicators, with optional rotation.

PropTypeDefaultDescription
label (required)string–Names the carousel for assistive technology.
children (required)ReactNode–One child per slide.
indexnumber–Controlled active slide. Pair with onIndexChange.
defaultIndexnumber0Initial slide when uncontrolled.
onIndexChange(index: number) => void–Called when the active slide changes.
slideSizestring"min(80cqw, 340px)"Width of one slide as a CSS length.
slideLabel(index: number, count: number) => string"2 of 5"Names each slide and its indicator.
intervalnumber–Milliseconds per slide. Adds a play control for rotation.
autoplaybooleanfalseStarts rotating on mount.
classNamestring–Class for the root section.

Keyboard interactions

KeysAction
ArrowLeft / ArrowRightMoves to the previous or next slide.
Home / EndJumps to the first or last slide.
TabMoves between the slide area, play control, active indicator, and arrows.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Carousel: Browse a row of slides by dragging, flicking, or arrowing through them. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components