---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Carousel

A strip of pictures that scroll sideways, two in view, with previous and next buttons, for a gallery or a product's photos, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `Carousel`.

## Try it

Step the strip with the narrow controls at its edges (each hides at its end), or scroll it sideways; press a panel to open it large, and close it with Escape or the cross.

The panels are colour blocks of our own standing in for photographs.

## When to use

- A strip of pictures that scroll sideways, two in view, with previous and next buttons, for a gallery or a product's photos.
- Also called: slideshow or image slider.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Carousel on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-carousel.json --yes
```

```text
Add the Goop Carousel to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { Carousel, CarouselItem } from '@/components/ui/goop/carousel';

<Carousel previousLabel="Previous picture" nextLabel="Next picture">
  <CarouselItem buttonLabel="Open the harbour picture" onClick={() => window.open('/pictures/harbour.jpg')}>
    <img src="/pictures/harbour.jpg" alt="" />
  </CarouselItem>
  <CarouselItem buttonLabel="Open the market picture" onClick={() => window.open('/pictures/market.jpg')}>
    <img src="/pictures/market.jpg" alt="" />
  </CarouselItem>
  <CarouselItem buttonLabel="Open the bridge picture" onClick={() => window.open('/pictures/bridge.jpg')}>
    <img src="/pictures/bridge.jpg" alt="" />
  </CarouselItem>
</Carousel>
```

- Fits: record: header (media: primary).
- height, width, padding, corner, text, motion: add no class for these.

## API reference

### Options

- `previousLabel?: string = 'Previous pictures'` — The previous control's name for a screen reader.
- `nextLabel?: string = 'Next pictures'` — The next control's name for a screen reader.
- `positionLabel?: (position: number, count: number) => string` — The words a screen reader is told when the strip moves ("2 of 5" by default).

### Parts

- `CarouselItem` — One picture of the strip; children: ReactNode — The picture, an `img` or your own, at the slide's width; buttonLabel?: string = 'Open picture' — The picture's button's spoken name, with `onClick`; onClick?: ComponentProps<'button'>['onClick'] — What a press on the picture does (open it large); without it, no button

- data-slot values (to select a part by): carousel, carousel-cell, carousel-frame, carousel-item, carousel-item-button, carousel-next, carousel-next-icon, carousel-position, carousel-previous, carousel-previous-icon, carousel-track, carousel-viewport

## Accessibility

- The native element answers the keyboard.
- hover, active, focus-visible, focus-within: the browser's own (:hover, :active, :focus-visible, :focus-within): write nothing

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Meta facts](/themes/trail/components/meta-facts): A strip of a record's short facts, such as its status, owner and dates, each a label over its value.
- [Feature grid](/themes/trail/components/feature-grid): A grid of feature cells, each an icon, a title and a line, for a marketing or a pricing page that lists what a product does.
- [Inline code](/themes/trail/components/inline-code): A word or short phrase of code inside running text, such as a key or a path.
- [Code block](/themes/trail/components/code-block): A block of code or a command with a copy button.
