← All Components
<mth-carousel>
Scroll-snap carousel supporting progressive CSS ::scroll-button enhancement, JS prev/next controls, RTL-aware roving focus indicators, and autoplay.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-carousel>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/carousel"></script>
<mth-carousel current-index="0" slides-per-view="1">Example</mth-carousel>import '@methane-ui/ui/carousel';
import '@methane-ui/react';
export function Example() {
return <mth-carousel current-index="0" slides-per-view="1">Example</mth-carousel>;
}<script setup lang="ts">
import '@methane-ui/ui/carousel';
</script>
<template>
<mth-carousel current-index="0" slides-per-view="1">Example</mth-carousel>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/carousel';
import { MthCarouselDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthCarouselDirective],
template: `<mth-carousel current-index="0" slides-per-view="1">Example</mth-carousel>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/carousel';
import MthCarousel from '@methane-ui/svelte/MthCarousel.svelte';
</script>
<MthCarousel current-index="0" slides-per-view="1">Example</MthCarousel>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
label | label | string | "" | Accessible region label for the carousel. |
currentIndex | current-index | number | 0 | Zero-based index of the currently active slide. |
slidesPerView | slides-per-view | number | 1 | Number of slides visible per viewport width. |
loop | loop | boolean | false | Wraps navigation from last slide back to first and vice versa. |
autoplay | autoplay | boolean | false | Automatically advances slides on the configured interval. |
interval | interval | number | 5000 | Autoplay interval duration in milliseconds. |
showControls | show-controls | boolean | true | Displays previous and next navigation buttons. |
showIndicators | show-indicators | boolean | true | Displays slide pagination indicator dots. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { index: number; total: number } | Fired when the active slide index changes. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowLeft / ArrowRight | both | slide indicator focused | navigates between slides (RTL-aware) |
| Home / End | both | slide indicator focused | jumps to first or last slide indicator |
| Enter / Space | both | prev/next/indicator focused | selects target slide and updates scroll track |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 3 APG keyboard transitions across LTR/RTL. | mth-carousel.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(autoplay). | Conformance suite |
| i18n | Routes 5 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |