Carousel

Material Design 3 carousel web components (lit-material-carousel, lit-material-carousel-item).

  • 2.7 KB gzipped
  • @lit-material/carousel 0.1.1
  • Renders on the server

Example

Install

npm install @lit-material/carousel @lit-material/tokens
import "@lit-material/carousel";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

A single slide inside lit-material-carousel โ€” purely presentational: it just sizes itself (via the --lit-material-carousel-item-width custom property the parent sets) and opts into scroll-snap, the same "container drives everything, item just renders" split lit-material-tab and lit-material-segmented-button use for their own parents.

Slots

SlotDescription
defaultThe slide's content (typically an image).
labelOptional caption, overlaid at the bottom with a scrim.

CSS parts

PartDescription
itemThe slide's container (background, shape, overflow clipping).
labelThe caption overlay, when the label slot has content.

Material Design 3 carousel โ€” a horizontally scrolling, scroll-snapping row of lit-material-carousel-item slides. No prior pattern in this repo to build on (there's no existing horizontal-scroll component), so this one is a fresh design: a native CSS scroll-snap track does the actual scrolling/snapping, and this component only adds item sizing (via the --lit-material-carousel-item-width custom property it sets, read by each item), optional prev/next buttons, and ArrowLeft/ArrowRight keyboard navigation across items.

Properties

PropertyAttributeTypeDefaultDescription
itemWidthitem-widthstring"280px"CSS length applied to every item's width (the --lit-material-carousel-item-width custom property).
showNavButtonsshow-nav-buttonsbooleantrueShows the overlaid previous/next buttons.

Slots

SlotDescription
defaultlit-material-carousel-item elements.

CSS parts

PartDescription
trackThe scrollable, scroll-snapping row.
prev-buttonThe previous-slide button. Only rendered while showNavButtons is set.
next-buttonThe next-slide button. Only rendered while showNavButtons is set.

Source on GitHub npm