Component reference
TiltedCarousel
A horizontal rail of separated, slightly tilted cards with optional continuous scroll.
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 {
TiltedCarousel,
CarouselContent,
CarouselSlide,
CarouselPrevious,
CarouselNext,
CarouselDots,
CarouselLiveRegion
} from "@pimolu/react";
const slides = [
{ title: "Atlas", note: "One token contract for every surface.", angle: 128 },
{ title: "Prism", note: "Six presets behind a single API.", angle: 164 },
{ title: "Signal", note: "Accessible primitives for dense layouts.", angle: 202 },
{ title: "Orbit", note: "Motion that respects reduced-motion.", angle: 238 },
{ title: "Terra", note: "Compositions that scale past the fold.", angle: 276 },
];
function artwork(angle: number) {
return {
backgroundImage: "linear-gradient(rgb(0 0 0 / 12%), rgb(0 0 0 / 78%)), " +
`linear-gradient(${angle}deg, var(--pimolu-surface), var(--pimolu-muted) 55%, var(--pimolu-background))`,
};
}
function Cover({ title, note, angle }: {
title: string;
note: string;
angle: number;
}) {
return (
<div
style={{
...artwork(angle),
display: "grid",
alignContent: "end",
gap: 6,
height: "100%",
padding: 20,
color: "white",
}}
>
<strong style={{ fontSize: "1.5rem" }}>{title}</strong>
<span style={{ fontSize: "0.875rem" }}>{note}</span>
</div>
);
}
function Gallery({ defaultIndex = 0, gap, tilt, limit = slides.length }: {
defaultIndex?: number;
gap?: number;
tilt?: number;
limit?: number;
}) {
return (
<TiltedCarousel
aria-label="Tilted gallery"
defaultIndex={defaultIndex}
gap={gap}
tilt={tilt}
loop
>
<CarouselContent>
{
slides.slice(0, limit).map((slide) => (<CarouselSlide key={slide.title}>
<Cover title={slide.title} note={slide.note} angle={slide.angle} />
</CarouselSlide>))
}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
<CarouselDots />
<CarouselLiveRegion />
</TiltedCarousel>
);
}
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.
Continuous scroll
Play the decorative service ticker in either direction. Its own pause button returns to manual navigation. Hover and focus pause motion temporarily, and reduced motion keeps the rail manual.
Named-part customization
Set a responsive card width and a track height, then apply local classes to the cards, controls and dots.
Usage
TiltedCarousel keeps a scroll-snap rail with visible gaps between cards. Use CarouselContent, CarouselSlide and the shared controls; the viewport is focusable and the arrow keys mirror RTL.
Use tilt={0} for straight cards and gap for spacing in pixels. slidesPerView is a target count and keeps a readable minimum card width. Use slideWidth to set your own responsive CSS length, and viewportHeight for the height of the track.
Use autoScroll for decorative cards. The rail stays manual if cards contain common interactive elements or explicit HTML IDs. Extra copies are visual only and hidden from assistive technology. autoScrollDirection sets the physical direction and speed sets pixels per second.
The automatic rail runs only when its cards overflow. It pauses on hover or focus. Its built-in button returns to manual navigation while paused; customize it with pauseLabel, resumeLabel and classNames.playback. Reduced motion keeps the manual controls available.
In manual mode, swiping, arrows, dots and keyboard navigation share the same page index. Use index and onIndexChange to control it. Navigation is omitted when the cards fit. On narrow screens, the controls sit below the cards to keep the card content clear.
TiltedCarousel and its stylesheet @pimolu/web-styles/tilted-carousel.css are available in the current workspace ahead of publication.
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.
TiltedCarouselProps
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 | 20 | Space between slides in pixels. Defaults to 20. |
classNames | (CarouselStageClassNames & { playback?: string; }) | — | Additive classes for the stable named parts, including the playback button. Named parts are listed in the Class names table. |
tilt | number | 3 | Maximum card rotation in degrees. Each card keeps a deterministic tilt from the fixed pattern, so the rail stays scattered while it moves. Defaults to 3. |
autoScroll | boolean | false | Loops decorative slides while there is overflow. Respects reduced motion. Defaults to false. |
autoScrollDirection | "ltr" | "rtl" | "ltr" | Direction of the continuous scroll: "ltr" moves cards left, "rtl" moves them right. Defaults to "ltr". |
speed | number | 40 | Continuous scroll speed in pixels per second. Defaults to 40. |
pauseLabel | string | "Pause automatic scroll" | Visible label for the automatic scroll pause button. |
resumeLabel | string | "Resume automatic scroll" | Visible label for the automatic scroll resume button. |
slidesPerView | number | — | Number of cards visible at once. Cards shrink so the requested count fits the rail; without it, cards use the natural editorial width. |
slideWidth | string | — | CSS width for each card. Overrides slidesPerView. |
viewportHeight | string | clamp(260px, 40vw, 380px) | CSS height for the track. Defaults to clamp(260px, 40vw, 380px). |
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: 20
Space between slides in pixels. Defaults to 20.
classNames(CarouselStageClassNames & { playback?: string; })No default extracted.
Additive classes for the stable named parts, including the playback button. Named parts are listed in the Class names table.
tiltnumberDefault: 3
Maximum card rotation in degrees. Each card keeps a deterministic tilt from the fixed pattern, so the rail stays scattered while it moves. Defaults to 3.
autoScrollbooleanDefault: false
Loops decorative slides while there is overflow. Respects reduced motion. Defaults to false.
autoScrollDirection"ltr" | "rtl"Default: "ltr"
Direction of the continuous scroll: "ltr" moves cards left, "rtl" moves them right. Defaults to "ltr".
speednumberDefault: 40
Continuous scroll speed in pixels per second. Defaults to 40.
pauseLabelstringDefault: "Pause automatic scroll"
Visible label for the automatic scroll pause button.
resumeLabelstringDefault: "Resume automatic scroll"
Visible label for the automatic scroll resume button.
slidesPerViewnumberNo default extracted.
Number of cards visible at once. Cards shrink so the requested count fits the rail; without it, cards use the natural editorial width.
slideWidthstringNo default extracted.
CSS width for each card. Overrides slidesPerView.
viewportHeightstringDefault: clamp(260px, 40vw, 380px)
CSS height for the track. Defaults to clamp(260px, 40vw, 380px).
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
8 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.
dotslivenextplaybackpreviousrootslideviewport
CSS variables
66 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-button-active-shadow--pimolu-button-active-transform--pimolu-button-font-weight--pimolu-button-height--pimolu-button-letter-spacing--pimolu-button-padding-x--pimolu-carousel-controls-center--pimolu-carousel-gap--pimolu-carousel-per-view--pimolu-control-background--pimolu-control-border--pimolu-control-border-width--pimolu-control-foreground--pimolu-control-shadow--pimolu-danger--pimolu-danger-foreground--pimolu-danger-hover--pimolu-focus-ring--pimolu-font-body--pimolu-foreground--pimolu-glass-bg--pimolu-glass-bg-hover--pimolu-glass-blur--pimolu-glass-border--pimolu-glass-shadow--pimolu-interaction-duration--pimolu-interaction-easing--pimolu-muted--pimolu-muted-foreground--pimolu-neutral--pimolu-neutral-foreground--pimolu-neutral-hover--pimolu-outline-hover-border--pimolu-primary--pimolu-primary-foreground--pimolu-primary-hover--pimolu-radius-full--pimolu-radius-lg--pimolu-radius-md--pimolu-radius-sm--pimolu-secondary--pimolu-secondary-foreground--pimolu-secondary-hover--pimolu-shadow-raised--pimolu-soft-border-color--pimolu-solid-border-color--pimolu-spacing-2--pimolu-spacing-3--pimolu-spacing-4--pimolu-spacing-5--pimolu-spacing-6--pimolu-spacing-8--pimolu-success--pimolu-success-foreground--pimolu-success-hover--pimolu-surface--pimolu-surface-foreground--pimolu-tilted-default-width--pimolu-tilted-slide-width--pimolu-tilted-tilt--pimolu-tilted-viewport-height--pimolu-warning--pimolu-warning-foreground--pimolu-warning-hover
Accessibility
- Give the rail an aria-label. Focus the viewport to use ArrowLeft, ArrowRight, Home or End. Use the pause button to turn continuous motion off.