Carousel
Move through a bounded or wrapping sequence of slides with direct controls.
Usage
Wrapping
Move from the last slide back to the first and from the first to the last.
Move from the last slide back to the first and from the first to the last.
<!-- Carousel / Wrapping -->
<script setup lang="ts">
import { CarouselRoot, CarouselTrack, CarouselSlide, CarouselPrevious, CarouselNext, CarouselPause, CarouselIndicatorGroup, CarouselIndicator } from '@sectile/vue/carousel'
const slides = ['foundation', 'adapters', 'frameworks']
</script>
<template>
<CarouselRoot :slides="slides" default-value="foundation">
<CarouselTrack>
<CarouselSlide v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselSlide>
</CarouselTrack>
<CarouselPrevious>Previous</CarouselPrevious>
<CarouselNext>Next</CarouselNext>
<CarouselPause>Pause</CarouselPause>
<CarouselIndicatorGroup>
<CarouselIndicator v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselIndicator>
</CarouselIndicatorGroup>
</CarouselRoot>
</template>Bounded
Reject values outside the configured minimum and maximum.
Reject values outside the configured minimum and maximum.
<!-- Carousel / Bounded -->
<script setup lang="ts">
import { CarouselRoot, CarouselTrack, CarouselSlide, CarouselPrevious, CarouselNext, CarouselPause, CarouselIndicatorGroup, CarouselIndicator } from '@sectile/vue/carousel'
const slides = ['foundation', 'adapters', 'frameworks']
</script>
<template>
<CarouselRoot :slides="slides" default-value="foundation">
<CarouselTrack>
<CarouselSlide v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselSlide>
</CarouselTrack>
<CarouselPrevious>Previous</CarouselPrevious>
<CarouselNext>Next</CarouselNext>
<CarouselPause>Pause</CarouselPause>
<CarouselIndicatorGroup>
<CarouselIndicator v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselIndicator>
</CarouselIndicatorGroup>
</CarouselRoot>
</template>Paused
Pause automatic carousel movement while keeping manual navigation available.
Pause automatic carousel movement while keeping manual navigation available.
<!-- Carousel / Paused -->
<script setup lang="ts">
import { CarouselRoot, CarouselTrack, CarouselSlide, CarouselPrevious, CarouselNext, CarouselPause, CarouselIndicatorGroup, CarouselIndicator } from '@sectile/vue/carousel'
const slides = ['foundation', 'adapters', 'frameworks']
</script>
<template>
<CarouselRoot :slides="slides" default-value="foundation">
<CarouselTrack>
<CarouselSlide v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselSlide>
</CarouselTrack>
<CarouselPrevious>Previous</CarouselPrevious>
<CarouselNext>Next</CarouselNext>
<CarouselPause>Pause</CarouselPause>
<CarouselIndicatorGroup>
<CarouselIndicator v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselIndicator>
</CarouselIndicatorGroup>
</CarouselRoot>
</template>Controlled
Let the parent own the current value and apply accepted changes back to the component.
Let the parent own the current value and apply accepted changes back to the component.
<!-- Carousel / Controlled -->
<script setup lang="ts">
import { CarouselRoot, CarouselTrack, CarouselSlide, CarouselPrevious, CarouselNext, CarouselPause, CarouselIndicatorGroup, CarouselIndicator } from '@sectile/vue/carousel'
const slides = ['foundation', 'adapters', 'frameworks']
</script>
<template>
<CarouselRoot :slides="slides" default-value="foundation">
<CarouselTrack>
<CarouselSlide v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselSlide>
</CarouselTrack>
<CarouselPrevious>Previous</CarouselPrevious>
<CarouselNext>Next</CarouselNext>
<CarouselPause>Pause</CarouselPause>
<CarouselIndicatorGroup>
<CarouselIndicator v-for="slide in slides" :key="slide" :value="slide">
{{ slide }}
</CarouselIndicator>
</CarouselIndicatorGroup>
</CarouselRoot>
</template>API
Vue package: @sectile/vue/carousel
CarouselRootCarouselViewportCarouselTrackCarouselIndicatorGroupCarouselPreviousCarouselNextCarouselPauseCarouselSlideCarouselIndicator
Props
CarouselRootProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
autoplayWhether the carousel advances without direct input.
defaultPausedInitial uncontrolled pause state.
defaultValueInitial value used when the component owns its state.
disabledWhether interaction is unavailable.
getIndicatorLabelReturns the accessible label announced for a carousel indicator.
getSlideLabelReturns the accessible label announced for a carousel slide.
labelAccessible name announced for the control.
modelValueCurrent value when state is controlled by the parent.
orientationAxis used for layout and keyboard movement.
pausedControlled pause state.
policiesBehavior policies that customize validation, movement, or selection.
slidesOrdered slide values managed by the carousel.
CarouselPartProps
asElement or component rendered for this part.
asChildWhether to merge this part into its single child instead of rendering a wrapper.
Slots
CarouselRootSlotProps
countNumber of values in the collection.
disabledWhether interaction is unavailable.
indexZero-based position in the parent collection.
pausedWhether automatic updates are paused.
valueCurrent value exposed by this contract.
CarouselSlideSlotProps
activeWhether this item is currently active.
countNumber of values in the collection.
disabledWhether interaction is unavailable.
indexZero-based position in the parent collection.
pausedWhether automatic updates are paused.
valueCurrent value exposed by this contract.
Events
CarouselRoot
announceEmitted when assistive feedback should be announced.
update:modelValueEmitted when the component requests a new controlled value.
update:pausedEmitted when the component requests a new pause state.
Other types
CarouselSlideLabelResolver
type CarouselSlideLabelResolver = NonNullable<CarouselRootProps['getSlideLabel']>CarouselIndicatorLabelResolver
type CarouselIndicatorLabelResolver = NonNullable<CarouselRootProps['getIndicatorLabel']>CarouselValueChangeHandler
type CarouselValueChangeHandler = (value: string | null) => voidCarouselPausedChangeHandler
type CarouselPausedChangeHandler = (value: boolean) => voidCarouselAnnounceHandler
type CarouselAnnounceHandler = (value: string) => voidParts
Shared scope: [data-scope="carousel"]. Combine it with a part selector to keep styles local to this component.
| Part | Selector | Role | Extra attributes |
|---|---|---|---|
root | [data-part="root"] | Defines the component boundary and owns its composed parts. | — |
viewport | [data-part="viewport"] | Clips and positions the currently visible content. | — |
track | [data-part="track"] | Defines the measurable path used by one or more thumbs. | — |
slide | [data-part="slide"] | Represents one carousel page. | — |
previous | [data-part="previous"] | Moves to the previous item or page. | — |
next | [data-part="next"] | Moves to the next item or page. | — |
pause | [data-part="pause"] | Pauses or resumes automatic movement. | — |
indicator-group | [data-part="indicator-group"] | Groups direct position controls. | — |
indicator | [data-part="indicator"] | Shows state or position without replacing the primary content. | — |
Keyboard interaction
| Key | Behavior |
|---|---|
| Arrow Left / Arrow Right | Move to the previous or next slide. |
| Home / End | Move to the first or last slide. |
| Enter / Space | Activate native previous, next, pause, or indicator controls. |
Accessibility
Slides, navigation controls, pause control, and indicators remain individually named and operable.
See the corresponding WAI-ARIA pattern for the host accessibility contract.
