Component reference
CoverflowCarousel
A centred card with scaled and rotated neighbours behind it.
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 {
CoverflowCarousel,
CarouselContent,
CarouselSlide,
CarouselPrevious,
CarouselNext,
CarouselDots,
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
},
];
function artwork(index: number) {
const slide = slides[index % slides.length];
const backgroundImage = "linear-gradient(rgb(0 0 0 / 12%), rgb(0 0 0 / 76%)), " +
"radial-gradient(circle at 70% 20%, " +
"color-mix(in srgb, var(--pimolu-primary) 42%, transparent), transparent 58%), " +
`linear-gradient(${slide.angle}deg, var(--pimolu-surface), var(--pimolu-background))`;
return { backgroundImage };
}
function Slide({ index }: {
index: number;
}) {
const slide = slides[index % slides.length];
return (
<div
style={{
...artwork(index),
display: "grid",
alignContent: "end",
gap: 4,
height: "100%",
padding: 20,
borderRadius: "calc(var(--pimolu-radius-lg) + 2px)",
overflow: "hidden",
color: "white",
}}
>
<strong>{slide.title}</strong>
<span style={{ fontSize: "0.875rem" }}>{slide.note}</span>
</div>
);
}
function Gallery({ defaultIndex = 0, gap, limit = slides.length, interactive = false }: {
defaultIndex?: number;
gap?: number;
limit?: number;
interactive?: boolean;
}) {
return (
<CoverflowCarousel
aria-label="Coverflow gallery"
loop
defaultIndex={defaultIndex}
gap={gap}
>
<CarouselContent>
{
slides.slice(0, limit).map((slide, index) => (<CarouselSlide
key={slide.title}
>
{
interactive
? (<div
className="min-w-0 rounded-lg border border-border p-6"
>
<h3>{slide.title}</h3>
<details>
<summary>About {slide.title}</summary>
<p className="text-sm text-muted">{slide.note}</p>
</details>
</div>)
: <Slide index={index} />
}
</CarouselSlide>))
}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
<CarouselDots />
<CarouselLiveRegion />
</CoverflowCarousel>
);
}
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 arrow, dot and keyboard change.
Localized labels
Previous, next, pagination and slide labels can follow the application language.
Editorial covers
A wider gap separates the cards and the third cover is selected initially.
Named-part customization
Apply local classes to the stage, cards, controls and dots without replacing the built-in depth, focus or disabled states.
Usage
CoverflowCarousel positions every slide from the active index instead of scrolling a track. Use CarouselContent, CarouselSlide and the shared controls.
The active card and immediate neighbours stay interactive. Cards rendered farther behind them are skipped by the keyboard and assistive technology.
In the current workspace, a single slide renders without arrows or pagination.
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.
CoverflowCarouselProps
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 | 0 | Space between slides in pixels. |
classNames | CarouselStageClassNames | — | 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: 0
Space between slides in pixels.
classNamesCarouselStageClassNamesNo 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
7 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.
dotslivenextpreviousrootslideviewport
CSS variables
16 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-control-background--pimolu-control-foreground--pimolu-focus-ring--pimolu-font-body--pimolu-foreground--pimolu-muted--pimolu-primary--pimolu-radius-full--pimolu-radius-sm--pimolu-shadow-raised--pimolu-spacing-2
Accessibility
- Check that arrow keys, dots and buttons move one shared index and that hidden cards are not announced as current.
- Reduced motion disables the transform transition; the focus ring and disabled edge controls remain visible.