Component reference
ThumbnailCarousel
A main stage with a thumbnail rail that shares one active index.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Width adapts to the available space
"use client";
import {
ThumbnailCarousel,
CarouselContent,
CarouselSlide,
CarouselPrevious,
CarouselNext,
CarouselThumbnails,
CarouselThumbnail,
CarouselLiveRegion
} from "@pimolu/react";
const slides = [
{
title: "Atlas",
note: "One token contract for colour, type, spacing and radius.",
angle: 122
},
{
title: "Prism",
note: "Six presets, light and dark, behind the same component API.",
angle: 158
},
{
title: "Signal",
note: "Accessible primitives for dense product surfaces.",
angle: 196
},
{
title: "Orbit",
note: "Feedback that stays calm when reduced motion is requested.",
angle: 236
},
{
title: "Terra",
note: "Compositions that scale past the first demo screen.",
angle: 274
},
];
const thumbnailColors = ["#4f46e5", "#0f172a", "#0ea5e9", "#db2777", "#ea580c"];
function artwork(index: number) {
const slide = slides[index % slides.length];
const backgroundImage = "radial-gradient(circle at 70% 20%, " +
"color-mix(in srgb, var(--pimolu-primary) 38%, transparent), transparent 58%), " +
`linear-gradient(${slide.angle}deg, var(--pimolu-surface), var(--pimolu-background))`;
return { backgroundImage };
}
function thumbnail(index: number) {
const slide = slides[index % slides.length];
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120">` +
`<rect width="160" height="120" fill="${thumbnailColors[index % thumbnailColors.length]}"/>` +
`<text x="12" y="76" fill="white" font-family="sans-serif" font-size="30">${slide.title}</text>` +
`</svg>`;
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
}
function Slide({ index, compact = false }: {
index: number;
compact?: boolean;
}) {
const slide = slides[index % slides.length];
return (
<div className="min-w-0 rounded-lg border border-border p-6">
<div
style={{
...artwork(index),
aspectRatio: compact ? "4 / 3" : "16 / 10",
borderRadius: "calc(var(--pimolu-radius-lg) - 4px)",
}}
/>
<div
className="flex flex-wrap items-center gap-3 min-w-0 justify-between"
style={{
marginTop: 12
}}
>
<h3>{slide.title}</h3>
<span className="text-sm text-muted leading-relaxed">{
String(index + 1).padStart(
2,
"0"
)
} / 05</span>
</div>
{!compact && <p className="text-sm text-muted">{slide.note}</p>}
</div>
);
}
function Gallery({ compact = false, defaultIndex = 0, gap, limit = slides.length }: {
compact?: boolean;
defaultIndex?: number;
gap?: number;
limit?: number;
}) {
return (
<ThumbnailCarousel
aria-label="Thumbnail gallery"
loop
defaultIndex={defaultIndex}
gap={gap}
>
<CarouselContent>
{
slides.slice(0, limit).map((slide, index) => (<CarouselSlide
key={slide.title}
>
<Slide index={index} compact={compact} />
</CarouselSlide>))
}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
<CarouselThumbnails>
{
slides.slice(0, limit).map((slide, index) => (<CarouselThumbnail
key={slide.title}
index={index}
src={thumbnail(index)}
alt={`${slide.title} view`}
/>))
}
</CarouselThumbnails>
<CarouselLiveRegion />
</ThumbnailCarousel>
);
}
export function DemoExample() {
return (
<Gallery />
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Controlled selection
The page owns the active index and receives every rail, arrow and keyboard change.
Localized labels
Previous, next, pagination and slide labels can follow the application language.
Compact editorial gallery
A smaller stage that keeps the thumbnail rail visible with five captioned images.
Named-part customization
Apply local classes to the stage, controls and thumbnail rail without replacing the built-in selection, focus or disabled states.
Uniform thumbnail rail
The thumbnail image has its own named part and a 1:1 default crop, so mixed source ratios no longer produce a saw-tooth rail. classNames.thumbnailImage targets the image itself.
Usage
Compose ThumbnailCarousel with CarouselContent, CarouselSlide, CarouselPrevious, CarouselNext, CarouselThumbnails and CarouselThumbnail. The rail and the arrow keys use the same engine state.
Pass loop, index/defaultIndex and onIndexChange like the other families. gap controls the slide spacing; the thumbnail rail keeps its own compact spacing.
Thumbnail images use a 1 / 1 crop by default, adjustable with --pimolu-carousel-thumbnail-aspect-ratio, so mixed source ratios keep a uniform rail. classNames.thumbnailImage targets the image; classNames.thumbnail remains the button.
In the current workspace, a single image renders without arrows or a thumbnail rail.
Available since 0.1.0-beta.9: the carousel families install from the published packages.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
ThumbnailCarouselProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | — | Slides: wrap each one in CarouselSlide. |
loop | boolean | false | Wraps from the last slide to the first one. Defaults to false. |
index | number | — | Controlled active index (zero-based). |
defaultIndex | number | 0 | Initial index when uncontrolled. Defaults to 0. |
onIndexChange | ((index: number) => void) | — | Called with the new index when navigation changes it. |
labels | Partial<CarouselLabels> | — | Overrides the built-in accessible labels. |
gap | number | 12 | Space between slides in pixels. |
classNames | Partial<Record<CarouselPartNames, string>> | — | Additive classes for the stable named parts. Named parts are listed in the Class names table. |
defaultValue | string | number | readonly string[] | — | Standard React/HTML attribute. |
className | string | — | Standard React/HTML attribute. |
style | CSSProperties | — | Standard React/HTML attribute. |
aria-label | string | — | Defines a string value that labels the current element. |
onClick | MouseEventHandler<HTMLDivElement> | — | Standard React/HTML attribute. |
showControlsOnMobile | boolean | true | Shows the previous/next controls on narrow viewports. Defaults to true. Swiping remains available when they are hidden. |
childrenRequiredReactNodeNo default extracted.
Slides: wrap each one in CarouselSlide.
loopbooleanDefault: false
Wraps from the last slide to the first one. Defaults to false.
indexnumberNo default extracted.
Controlled active index (zero-based).
defaultIndexnumberDefault: 0
Initial index when uncontrolled. Defaults to 0.
onIndexChange((index: number) => void)No default extracted.
Called with the new index when navigation changes it.
labelsPartial<CarouselLabels>No default extracted.
Overrides the built-in accessible labels.
gapnumberDefault: 12
Space between slides in pixels.
classNamesPartial<Record<CarouselPartNames, string>>No default extracted.
Additive classes for the stable named parts. Named parts are listed in the Class names table.
defaultValuestring | number | readonly string[]No default extracted.
Standard React/HTML attribute.
classNamestringNo default extracted.
Standard React/HTML attribute.
styleCSSPropertiesNo default extracted.
Standard React/HTML attribute.
aria-labelstringNo default extracted.
Defines a string value that labels the current element.
onClickMouseEventHandler<HTMLDivElement>No default extracted.
Standard React/HTML attribute.
showControlsOnMobilebooleanDefault: true
Shows the previous/next controls on narrow viewports. Defaults to true. Swiping remains available when they are hidden.
Class names
10 partsPass these keys to classNames to style the matching element. A part renders only when its element or state is present; keys are additive and never replace the component class.
dotslivenextpreviousrootslidethumbnailthumbnailImagethumbnailsviewport
CSS variables
18 variablesCustom properties read by this component's shared stylesheet. Set them on the component, an ancestor or :root; they fall back to the theme when unset.
--pimolu-background--pimolu-border--pimolu-carousel-controls-center--pimolu-carousel-gap--pimolu-carousel-per-view--pimolu-carousel-thumbnail-aspect-ratio--pimolu-control-background--pimolu-control-foreground--pimolu-focus-ring--pimolu-font-body--pimolu-foreground--pimolu-muted--pimolu-primary--pimolu-radius-full--pimolu-radius-lg--pimolu-radius-sm--pimolu-shadow-raised--pimolu-spacing-2
Accessibility
- Every thumbnail is a real button with aria-current, so pointer and keyboard users can switch the collection.
- Verify previous/next, the rail selection and the live region; images need a meaningful alt in the thumbnail rail.