# Carousel

A horizontal carousel: touch dragging (dual threshold on displacement / velocity), autoplay (paused on hover and while dragging), two modes — loop wrap-around and boundary clamping — a dots indicator (bottom / overlay) and desktop arrows. All page-index math consumes @lh-ui/share/core/carousel.

Carousel
<template>
  <div class="demo-col" style="gap: 18px">
    <div class="demo-row" style="max-width: 420px">
      <LhCarousel :autoplay="3000" :height="160">
        <div class="carousel-page">Ink</div>
        <div class="carousel-page">Danqing</div>
        <div class="carousel-page">Gongbi</div>
      </LhCarousel>
    </div>
    <div class="demo-row" style="max-width: 420px">
      <LhCarousel v-model="page" :loop="false" :autoplay="0" show-arrow :height="140">
        <div class="carousel-page">Page 1</div>
        <div class="carousel-page">Page 2</div>
      </LhCarousel>
    </div>
    <p class="demo-note">Non-loop controlled current page: {{ page }} (arrow keys ←/→ also navigate)</p>
  </div>
</template>

<script>
export default {
  data: () => ({
    page: 0,
  }),
}
</script>

# Props

Prop Description Type Default
v-model / modelValue Current page index (controlled; self-advances when not passed) number —
autoplay Autoplay interval in ms (0 / not passed = no autoplay) number 0
loop Loop wrap-around boolean true
indicator Indicator style 'dots' \| 'none' 'dots'
indicatorPosition Indicator position 'bottom' \| 'overlay' 'bottom'
height Height in px number 200
showArrow Show the left / right arrows (desktop) boolean false
disabled Disabled boolean false
ariaLabel Accessibility name (falls back to the page-number announcement) string —
sx sx shorthand layout props — —

# Events

Event Description Callback args
input v-model event (controlled page index write-back) (value: number)
change Emitted when the page switches (value: number)

# Slots

Slot Description
default Carousel page content (one page per direct child node)
item Named per-page slot { index } (alternative to default)

# Methods

Method Description
prev() / next() Previous page / next page
goTo(index) Jump to a given page

# Accessibility

  • Root element role="region" + aria-roledescription="carousel"; the accessible name comes from ariaLabel or the page-number announcement; arrow keys ←/→ navigate; non-active pages get aria-hidden
Last Updated: 12/4/2026, 12:49:57 AM

Copyright © 2024-2026 FengMo WenXue