Carousel
Secondary items in short horizontal space: similar species, related products, photo sets, at least four. Base UI has no carousel, so it is composed from a Scroll Area in its rail kind (the track, whose native scrollbar is the position rail), a list of slides each labelled "n of N", Previous and Next buttons and a polite count. It never autoplays or loops, and it has no dots.
import { Carousel, CarouselPhoto, CarouselSlide } from '@fairgarden/design/content/carousel'
The first slide aligns to the container's start edge and the end bleeds to the viewport edge (to the field's edge inside a forest or royal field), with the next slide peeking. Snapping is the browser's own: swipe and trackpad come to rest on a slide's start, and the buttons and the arrow, Home and End keys on the focused track scroll straight to where snap would put the slide, in one movement (at once under reduced motion). A vertical wheel never moves the track and scrolls the page. At either end that button is hidden with its space kept, and the count states the position. When every slide fits, the controls go and the slides sit as a static row.
Card carousels
Card carousels
kind="cards" holds CarouselSlides. Counts come from the carousel's own width and only rise with it: image and portrait cards run 2 + peek (1 + peek below 360 px); with post, editorial post cards run 1 at about 85% at base, 2 + peek from 768 px and 3 + peek from 1024 px. Without container queries the slide widths are percentages of the track, so the peek still holds.
Similar Species
1 of 6
Related Stories
1 of 5
Photo carousel
Photo carousel
kind="photos" holds CarouselPhotos: a photo figure whose caption stays visible, right-flush. Below 1024 px of container each slide is about 88% of the track, and its photo stops at 480 px tall: a portrait photo narrows to its own ratio at that height, uncropped, with its caption under it. From 1024 px the carousel becomes a fixed strip: a 480 px track height, each slide as wide as its photo at that height (from ratio), so nothing is cropped, with 12 px gaps.
1 of 8
7 more images (example.org/wood-thrush/photos)
In print
Controls, count, peek and rail are hidden. Card slides print as a 2-up grid; photo sets of up to 6 print 3-up at their own ratios. A larger photo set prints its first slide and caption and "n more images (printUrl)".
API Reference
Carousel
The carousel. The browser’s own scroll snap places every slide: a swipe or trackpad scroll comes to rest on a slide’s start, and the Previous and Next buttons and the arrow, Home and End keys on the focused track move it one slide at a time to exactly the position snap would choose. In print, card slides become a 2-up grid and photo sets of up to 6 a 3-up grid; a larger photo set prints its first slide and “n more images (short URL)".
| Prop | Type | Description |
|---|---|---|
label | | The carousel’s accessible name, e.g. “Similar species”. |
controlLabels | | Previous and Next accessible names. Default “Previous” and “Next”. |
header | | The module header (§11.8), above the track. |
kind | |
|
post | | Editorial post cards: 1 landscape slide at ≈ 85% at base, 2 + peek from
768 px, 3 + peek from 1024 px of container [D186]. Default |
primary | | Primary Radix scale: buttons, count, rail and thumb, and the slides’ inherited primary. Never defaulted; omitted, it inherits the scope [D133]. |
printUrl | | The short URL printed after a photo set of more than 6 slides: “5 more images (example.org/gallery)". No protocol. |
secondary | | Secondary Radix scale, passed to the slides; no carousel part uses it. Never defaulted. |
children | | The slides: |
CarouselSlide
One slide, labelled “n of N” for assistive technology. It snaps to its start; slides are focusable only through their own links.
| Prop | Type | Description |
|---|---|---|
ratio | | The photo’s width ÷ height (e.g. |
CarouselPhoto
A photo slide: a §8.5 photo Figure with the image at its own ratio and the caption right-flush under it.
| Prop | Type | Description |
|---|---|---|
alt | | The alternative text; empty only for a decorative photo. |
caption | | The caption: what to notice. Always visible, right-flush. |
credit | | The credit, in the same run: “Photo: Name / Program”. |
imgProps | | Image |
ratio | | The photo’s own width ÷ height (e.g. |
src | | The image source. |
Additional types
CarouselPhotoProps
Props for CarouselPhoto: the image, its ratio and the caption.
type CarouselPhotoProps = {
/** The image source. */
src: string;
/** The alternative text; empty only for a decorative photo. */
alt: string;
/** The photo's own width ÷ height (e.g. `3 / 2`), so the strip never crops it. */
ratio: number;
/** The caption: what to notice. Always visible, right-flush. */
caption?: React.ReactNode;
/** The credit, in the same run: "Photo: Name / Program". */
credit?: React.ReactNode;
/** Image `srcSet`, `sizes`, `loading` and other attributes. */
imgProps?: Omit<
React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,
'src' | 'alt'
>;
}CarouselProps
Props for Carousel: section props, the kind (and post for cards), label, header, slides and the color axes.
type CarouselProps = CarouselCardsProps | CarouselPhotosPropsCarouselSlideProps
Props for CarouselSlide: li props and, for photo slides, the photo’s ratio.
type CarouselSlideProps = React.ClassAttributes<HTMLLIElement> &
React.LiHTMLAttributes<HTMLLIElement> & { ratio?: number }Specification: DESIGN-SYSTEM.md §12.4 (carousel; desktop counts and the photo strip per D186), §10.19 (scroll area) and §5.10.2 (module reflow).