Keyboard shortcut: Ctrl + K
Get started

Carousel

VCarousel displays slides in a scrollable track with optional controls, indicators and autoplay.

Usage

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VCarousel, VCarouselItem } from 'vectis-ui'

const slide = ref(0)
</script>

<template>
  <VCarousel v-model="slide" label="Gallery">
    <VCarouselItem><p class="slide">First slide</p></VCarouselItem>
    <VCarouselItem><p class="slide">Second slide</p></VCarouselItem>
    <VCarouselItem><p class="slide">Third slide</p></VCarouselItem>
  </VCarousel>
</template>

<style scoped>
.slide {
  display: grid;
  place-items: center;
  block-size: 12rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  background: var(--vectis-color-surface-muted);
}
</style>

Examples

Items per view

itemsPerView sets the maximum visible slides. itemMinSize reduces that number when the container narrows.

vue
<script setup lang="ts">
import { VCarousel, VCarouselItem } from 'vectis-ui'

const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <VCarousel label="Three at a time" :items-per-view="3" :item-min-size="180">
    <VCarouselItem v-for="(hue, i) in hues" :key="hue">
      <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
    </VCarouselItem>
  </VCarousel>
</template>

<style scoped>
.slide {
  display: grid;
  place-items: center;
  block-size: 10rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
</style>

Peek

peek leaves part of the next slide visible, including the gap.

vue
<script setup lang="ts">
import { VCarousel, VCarouselItem } from 'vectis-ui'

const products = ['Kettle', 'Toaster', 'Blender', 'Grinder', 'Scale', 'Press']
const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <VCarousel label="Product list" :items-per-view="2" peek="3rem">
    <VCarouselItem v-for="(product, i) in products" :key="product">
      <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hues[i]})` }">{{ product }}</p>
    </VCarouselItem>
  </VCarousel>
</template>

<style scoped>
.slide {
  display: grid;
  place-items: center;
  block-size: 10rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
</style>

Effects

Choose slide, fade or scale. Fade requires one slide per view and no peek; otherwise it falls back to slide.

vue
slide
fade
scale
<script setup lang="ts">
import { VCarousel, VCarouselItem, VTypography, type CarouselEffect } from 'vectis-ui'

const effects: CarouselEffect[] = ['slide', 'fade', 'scale']
const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <div v-for="effect in effects" :key="effect" class="group">
    <VTypography variant="overline" tone="muted">{{ effect }}</VTypography>
    <VCarousel :effect="effect" :label="`The ${effect} effect`">
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>
</template>

<style scoped>
.group {
  display: grid;
  gap: var(--vectis-space-2);
}
.slide {
  display: grid;
  place-items: center;
  block-size: 10rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
</style>

Orientation

Vertical carousels require an explicit height.

vue
horizontal
vertical
<script setup lang="ts">
import { VCarousel, VCarouselItem, VTypography } from 'vectis-ui'

const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <div class="group">
    <VTypography variant="overline" tone="muted">horizontal</VTypography>
    <VCarousel label="Horizontal gallery">
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>

  <div class="group">
    <VTypography variant="overline" tone="muted">vertical</VTypography>
    <VCarousel orientation="vertical" height="14rem" label="Vertical gallery">
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide fill" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>
</template>

<style scoped>
.group {
  display: grid;
  gap: var(--vectis-space-2);
}
.slide {
  display: grid;
  place-items: center;
  block-size: 10rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
/* Let content fill the carousel's assigned slide height. */
.fill {
  block-size: 100%;
}
</style>

Custom icons

Customize controls with prevIcon, nextIcon and their accessible labels.

vue
chevrons
carets
<script setup lang="ts">
import { VCarousel, VCarouselItem, VTypography } from 'vectis-ui'
import {
  chevron_left as chevronLeft,
  chevron_right as chevronRight,
  expand_less as expandLess,
  expand_more as expandMore,
} from 'vectis-ui/icons'

const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <div class="group">
    <VTypography variant="overline" tone="muted">chevrons</VTypography>
    <VCarousel label="Chevron controls" :prev-icon="chevronLeft" :next-icon="chevronRight">
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>

  <div class="group">
    <VTypography variant="overline" tone="muted">carets</VTypography>
    <VCarousel
      orientation="vertical"
      height="14rem"
      label="Caret controls"
      :prev-icon="expandLess"
      :next-icon="expandMore"
    >
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide fill" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>
</template>

<style scoped>
.group {
  display: grid;
  gap: var(--vectis-space-2);
}
.slide {
  display: grid;
  place-items: center;
  block-size: 10rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
.fill {
  block-size: 100%;
}
</style>

Placements

controls and indicators independently accept inside, outside or false.

vue
arrows inside, dots outside
arrows inside, dots inside
arrows outside, dots outside
arrows outside, dots inside
<script setup lang="ts">
import {
  VCarousel,
  VCarouselItem,
  VTypography,
  type CarouselControls,
  type CarouselIndicators,
} from 'vectis-ui'

const placements: {
  caption: string
  controls: CarouselControls
  indicators: CarouselIndicators
}[] = [
  { caption: 'arrows inside, dots outside', controls: 'inside', indicators: 'outside' },
  { caption: 'arrows inside, dots inside', controls: 'inside', indicators: 'inside' },
  { caption: 'arrows outside, dots outside', controls: 'outside', indicators: 'outside' },
  { caption: 'arrows outside, dots inside', controls: 'outside', indicators: 'inside' },
]

const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <div v-for="placement in placements" :key="placement.caption" class="group">
    <VTypography variant="overline" tone="muted">{{ placement.caption }}</VTypography>
    <VCarousel
      :controls="placement.controls"
      :indicators="placement.indicators"
      :label="placement.caption"
    >
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>
</template>

<style scoped>
.group {
  display: grid;
  gap: var(--vectis-space-2);
}
.slide {
  display: grid;
  place-items: center;
  block-size: 10rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
</style>

Jumps

Multi-page moves jump directly by default. noJump scrolls through the intervening slides.

vue
straight there, the default
the whole travel
<script setup lang="ts">
import { VCarousel, VCarouselItem, VTypography } from 'vectis-ui'

const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <div class="group">
    <VTypography variant="overline" tone="muted">straight there, the default</VTypography>
    <VCarousel effect="fade" label="Jumping gallery">
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>

  <div class="group">
    <VTypography variant="overline" tone="muted">the whole travel</VTypography>
    <VCarousel effect="fade" no-jump label="Travelling gallery">
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>
</template>

<style scoped>
.group {
  display: grid;
  gap: var(--vectis-space-2);
}
.slide {
  display: grid;
  place-items: center;
  block-size: 10rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
</style>

Loop

loop wraps navigation from the last position to the first and back.

vue
<script setup lang="ts">
import { VCarousel, VCarouselItem } from 'vectis-ui'

const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <VCarousel loop label="Looping gallery">
    <VCarouselItem v-for="(hue, i) in hues" :key="hue">
      <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
    </VCarouselItem>
  </VCarousel>
</template>

<style scoped>
.slide {
  display: grid;
  place-items: center;
  block-size: 12rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
</style>

Autoplay

autoplay sets an interval in milliseconds. Hover and focus pause it; reduced motion disables it. Add a pause button by setting the interval to 0.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VButton, VCarousel, VCarouselItem } from 'vectis-ui'

/* Provide a pause control for users who cannot hover or focus the carousel. */
const paused = ref(false)

const hues = [220, 280, 340, 20, 90, 160]
</script>

<template>
  <div class="group">
    <VButton variant="outline" tone="neutral" size="sm" class="stop" @click="paused = !paused">
      {{ paused ? 'Resume' : 'Pause' }}
    </VButton>

    <VCarousel :autoplay="paused ? 0 : 3000" label="Rotating gallery">
      <VCarouselItem v-for="(hue, i) in hues" :key="hue">
        <p class="slide" :style="{ background: `oklch(0.45 0.15 ${hue})` }">{{ i + 1 }}</p>
      </VCarouselItem>
    </VCarousel>
  </div>
</template>

<style scoped>
.group {
  display: grid;
  gap: var(--vectis-space-3);
}
.stop {
  justify-self: start;
}
.slide {
  display: grid;
  place-items: center;
  block-size: 12rem;
  margin: 0;
  border-radius: var(--vectis-radius-surface);
  color: var(--vectis-color-text-on-accent);
  font-size: var(--vectis-text-heading-3-size);
  font-weight: var(--vectis-text-heading-3-weight);
}
</style>

API

Props

VCarousel
PropTypeDefault
itemsPerViewnumber1
Maximum slides per view. The container width and itemMinSize determine how many fit.
itemMinSizenumber | stringnone
Minimum slide size. Numbers use pixels; strings use CSS lengths.
peeknumber | stringnone
Visible portion of the next slide, including the gap. Incompatible with fade.
gapnumber | stringnone
Spacing between slides.
orientationCarouselOrientation'horizontal' | 'vertical''horizontal'
Horizontal or vertical scrolling.
effectCarouselEffect'slide' | 'fade' | 'scale''slide'
Slide, fade or scale. Fade falls back to slide unless one slide is visible with no peek.
heightnumber | stringnone
Viewport height. Required for vertical scrolling.
loopbooleanfalse
Wraps between the first and last positions. Controls remain disabled when there is only one position.
noJumpbooleanfalse
Scrolls through intervening slides for multi-page moves. Reduced motion still uses instant movement.
autoplaynumber0
Advance interval in milliseconds; 0 disables it. Pauses on hover/focus and respects reduced motion. Provide a pause control, especially when looping.
controlsCarouselControlsfalse | 'inside' | 'outside''inside'
Previous/next control placement: inside, outside or hidden.
indicatorsCarouselIndicatorsfalse | 'inside' | 'outside''outside'
Indicator placement: inside, outside or hidden.
controlsVisibilityCarouselControlsVisibility'always' | 'hover''always'
Always visible or visible on hover/focus. Touch users always see them.
prevIconIconSourcenone
Previous control icon. Defaults to the orientation’s arrow.
nextIconIconSourcenone
Next control icon. Defaults to the orientation’s arrow.
prevLabelstringnone
Accessible previous control name. Defaults to the dictionary.
nextLabelstringnone
Accessible next control name. Defaults to the dictionary.
labelstringnone
Accessible carousel name. Use distinct names for multiple carousels.
v-modelnumber0
Current position, starting at 0. Refers to the first fully visible slide and is clamped to reachable positions.
VCarouselItem
PropTypeDefault
indexnumber0
Slide index assigned by the carousel. Do not set manually.

Slots

VCarousel
SlotType
default{}
Slides. Keep their count consistent between server and client rendering.
controlsCarouselControlsSlotProps
Replaces and positions controls. Receives previous, next, atStart, atEnd, index, count, pageCount and orientation.
indicatorsCarouselIndicatorsSlotProps
Replaces the indicator bar. Receives index, count, pageCount, goTo and orientation. Render one control per page, not per slide.
indicatorCarouselIndicatorSlotProps
Content inside an indicator button. Receives index and active.
VCarouselItem
SlotType
default{}
Slide content.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export interface CarouselControlsSlotProps {
  previous: () => void
  next: () => void
  atStart: boolean
  atEnd: boolean
  index: number
  count: number
  pageCount: number
  orientation: CarouselOrientation
}
export interface CarouselIndicatorSlotProps {
  index: number
  active: boolean
}
export interface CarouselIndicatorsSlotProps {
  index: number
  count: number
  pageCount: number
  goTo: (index: number) => void
  orientation: CarouselOrientation
}
export type CarouselOrientation = 'horizontal' | 'vertical'
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender

CSS variables

TokenValue
--vectis-control-size-carousel-block24rem
--vectis-control-size-carousel-indicator0.625rem
--vectis-control-size-carousel-indicator-active1.25rem