Carousel
Horizontal carousel: touch dragging (dual displacement / velocity thresholds), autoplay (paused during hover and drag), both loop-wrap and boundary-clamp modes, dots indicator (in bottom document flow or as an overlay) and desktop arrows. All page-index math consumes @lh-ui/share/core/carousel.
Basic Usage
Basic usage (autoplay + loop)
Ink wash
Danqing
Gongbi
vue
<script setup lang="ts">
import { LhCarousel } from '@lh-ui/vue3'
</script>
<template>
<div class="demo-row">
<LhCarousel :autoplay="3000" :height="160" style="max-width: 420px;">
<div>Ink wash</div>
<div>Danqing</div>
<div>Gongbi</div>
</LhCarousel>
</div>
</template>vue
<script>
import { LhCarousel } from '@lh-ui/vue3'
export default {
components: { LhCarousel },
}
</script>
<template>
<div class="demo-row">
<LhCarousel :autoplay="3000" :height="160" style="max-width: 420px;">
<div>Ink wash</div>
<div>Danqing</div>
<div>Gongbi</div>
</LhCarousel>
</div>
</template>Non-loop + desktop arrows + controlled
Non-loop (stops at edges) + arrows + v-model
Page 1
Page 2
Current page: 0
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhCarousel } from '@lh-ui/vue3'
const page = ref(0)
</script>
<template>
<div class="demo-row">
<LhCarousel v-model="page" :loop="false" show-arrow :height="140" style="max-width: 420px;">
<div>Page 1</div>
<div>Page 2</div>
</LhCarousel>
</div>
<p>Current page: {{ page }}</p>
</template>vue
<script>
import { LhCarousel } from '@lh-ui/vue3'
export default {
components: { LhCarousel },
data() {
return { page: 0 }
},
}
</script>
<template>
<div class="demo-row">
<LhCarousel v-model="page" :loop="false" show-arrow :height="140" style="max-width: 420px;">
<div>Page 1</div>
<div>Page 2</div>
</LhCarousel>
</div>
<p>Current page: {{ page }}</p>
</template>Carousel API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
| v-model / modelValue | Current page index (controlled; runs on its own 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 left/right arrows (desktop) | boolean | false |
| disabled | Disabled | boolean | false |
| ariaLabel | Accessible name (falls back to page-number announcement when not passed) | string | — |
| sx | sx quick-layout props | LhSxProps | — |
Events
| Event | Description | Callback |
|---|---|---|
| update:modelValue | Controlled page index write-back | (value: number) |
| change | Page switch | (value: number) |
Slots
| Slot | Description |
|---|---|
| default | Carousel page content (each direct child node is one page) |
| item | Named per-page slot { index } (either this or default) |
Methods (via ref)
| Method | Description |
|---|---|
| prev() / next() | Previous page / next page |
| goTo(index) | Jump to the specified page |
Accessibility
- The root element has
role="region"+aria-roledescription="carousel"; its accessible name comes fromariaLabelor the page-number announcement; arrow keys ←/→ turn pages; non-active pages arearia-hidden

