Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Data

Carousel <pm-carousel>

Carousel built on native scroll-snap (swipe, trackpad and keyboard scrolling just work).

Full screen

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/card'; import '@prismora/elements/carousel'; </script> <pm-carousel label="Surface styles" per-view="2"> <pm-card heading="Glass" description="Frosted, translucent surfaces."> <div slot="media" style="aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--pm-color-accent-solid), var(--pm-color-info-solid))"></div> </pm-card> <pm-card heading="Gradient" description="OKLCH-interpolated fills."> <div slot="media" style="aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--pm-color-secondary-solid), var(--pm-color-warning-solid))"></div> </pm-card> <pm-card heading="Neumorphic" description="Soft, extruded shapes."> <div slot="media" style="aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--pm-color-neutral-solid), var(--pm-color-border-strong))"></div> </pm-card> <pm-card heading="Flat" description="Solid fills, hairline borders."> <div slot="media" style="aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--pm-color-success-solid), var(--pm-color-info-solid))"></div> </pm-card> <pm-card heading="Outline" description="Lines only, no fills."> <div slot="media" style="aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--pm-color-danger-solid), var(--pm-color-warning-solid))"></div> </pm-card> </pm-carousel>

Overview

Optional autoplay (autoplay="5000") moves on every so many milliseconds. It waits while the pointer is over the carousel, while it is off screen and while the tab is hidden; it stops for good once keyboard focus moves into it (until Play is pressed); and it is off with reduced motion. The Play / Pause button (WCAG 2.2.2) shows whenever autoplay can run; paused, play() and stop() drive it from code.

Attributes

AttributeTypeDefaultDescription
prev-label
prop: prevLabel
string—Name of the previous button (default "Previous slide"), for another language.
next-label
prop: nextLabel
string—Name of the next button (default "Next slide").
labelstringCarouselAccessible name (and visible label where the component shows one).
per-view
prop: perView
number1Slides visible at once.
gapstring—CSS gap between slides.
loopbooleanfalseWrap around at the ends.
autoplaynumber0Autoplay interval in ms (0 = off; at least 1500).
hide-controls
prop: hideControls
booleanfalseHide the previous/next buttons.
hide-dots
prop: hideDots
booleanfalseHide the slide position dots.
pausedbooleanfalseAutoplay is stopped (by the Play / Pause button, keyboard focus, or code).
pause-label
prop: pauseLabel
string—Name of the button while slides play (default "Pause slides").
play-label
prop: playLabel
string—Name of the button while paused (default "Play slides").

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-changeonPmChangeActive slide changed.
pm-toggleonPmToggleAutoplay was paused or resumed (paused).

Slots

SlotDescription
(default)Slides (any elements).

Methods

play(), stop(), goTo(), next(), prev()

Used in templates

Product page