Skip to content
Content Blocks docsv0.8.0Website

Docs / Components

<content-carousel>

Slides that move sideways, built on Swiper, with labelled controls and a pause button when they move on their own.

Import it on its own, for a bundler
import '@content-blocks/js/components/content-carousel';

Examples

Three photos of the realms, one at a time, with arrows and dots. Options are passed straight to Swiper.

Open on its own

Anatomy

Content goes into the component's slots, chosen with the slot attribute on each child.

flowchart LR
  root["#lt;content-carousel#gt;"]:::component
  root --> s0["<b>no slot (default)</b><br/>Default slot, same as content slot."]
  root --> s1["<b>slot=#quot;content#quot;</b><br/>This slot will usually serve a content hero block or image."]
  classDef component fill:#141413,color:#faf9f5,stroke:#141413
The slots of <content-carousel>
SlotWhat goes in it
(default)Default slot, same as content slot.
slot="content"This slot will usually serve a content hero block or image.

Properties

Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.

AttributeTypeDefaultDescription
classesresponsiveString–Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side".
init-methodSelect

load · init

'load'Not documented yet
labelString'Carousel'The accessible name of the carousel, read by screen readers when they reach it.
next-labelString'Next slide'The accessible name of the next slide button.
paddingresponsiveString–Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem".
pause-labelString'Pause the slides'The accessible name of the button that stops slides that move on their own.
play-labelString'Play the slides'The accessible name of the button that starts the slides moving again.
prev-labelString'Previous slide'The accessible name of the previous slide button.
swiper-optionsJSON'{"slidesPerView": 1, "slidesPerGroup": 1, "autoplay": true, "loop": false}'Not documented yet

Events and methods

sequenceDiagram
  participant Page
  participant C as content-carousel
  Page->>C: focusin event
  Page->>C: setSwiperOptions event
What <content-carousel> listens for and what it tells the page