Carousel
A set of slides shown one at a time, with optional rotation.
Example
Invoice template
Roadmap template
Retro template
<focsd-carousel label="Featured templates"> <focsd-carousel-slide><p>Invoice template</p></focsd-carousel-slide> <focsd-carousel-slide><p>Roadmap template</p></focsd-carousel-slide> <focsd-carousel-slide><p>Retro template</p></focsd-carousel-slide></focsd-carousel>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-carousel.js';</script>
<focsd-carousel label="Featured templates">…</focsd-carousel>import { Carousel } from '@focsd-dev/react';
export function Example() { return <Carousel label="Featured templates">…</Carousel>;}<script setup>import '@focsd-dev/components/focsd-carousel.js';</script>
<template> <focsd-carousel label="Featured templates">…</focsd-carousel></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-carousel.js';
// template<focsd-carousel label="Featured templates">…</focsd-carousel><script> import '@focsd-dev/components/focsd-carousel.js';</script>
<focsd-carousel label="Featured templates">…</focsd-carousel>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
autoplay | autoplay | number | 0 |
index | index | number | 0 |
Methods
| Method | Description |
|---|---|
go(index) | Show slide index (wraps around). |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
CSS parts
Style the inside of the component with ::part(), for example focsd-carousel::part(carousel).
| Part | Description |
|---|---|
carousel | The carousel element. |
control | The control element. |
controls | The row of carousel buttons. |
next | The next slide button. |
previous | The previous slide button. |
rotation | The play or pause button (with `autoplay`). |
slides | The container of the slides. |
Accessibility
- APG carousel: a labeled region with
aria-roledescription="carousel"; slides are groups named "1 of 3". Hidden slides areinert. - With
autoplay, a Stop/Start rotation button appears; rotation pauses while hovered or focused and starts paused under reduced motion. - Slide changes are announced politely except while rotating.
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.