Featured content
Show a few highlights, such as product stages or testimonials, one at a time in limited space.
Components / Display
A swipeable snap carousel with arrows, slide dots, and accessible autoplay.
Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.
bunx --bun @getweini/cli@latest add carouselImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
ShowingPlan
<script setup lang="ts">
import { ref } from 'vue'
import Carousel from './components/ui/carousel/Carousel.vue'
import CarouselItem from './components/ui/carousel/CarouselItem.vue'
const index = ref(0)
const slides = ['Plan', 'Design', 'Build', 'Ship']
const messages = {
label: 'Product stages',
previous: 'Previous stage',
next: 'Next stage',
slide: (n: number, total: number) => `Stage ${n} of ${total}`,
goTo: (n: number) => `Go to stage ${n}`,
pause: 'Pause rotation',
play: 'Start rotation',
roleDescription: 'carousel',
slideRoleDescription: 'slide',
}
</script>
<template>
<div class="grid max-w-xl gap-2">
<Carousel v-model="index" :messages="messages" controls-placement="outside">
<CarouselItem v-for="slide in slides" :key="slide">
<div
class="flex h-48 items-center justify-center rounded-xl border border-border bg-card text-2xl font-semibold text-card-foreground"
>
{{ slide }}
</div>
</CarouselItem>
</Carousel>
<p class="text-sm text-muted-foreground">Showing{{ slides[index] }}</p>
</div>
</template>Wrap each slide in CarouselItem. Bind v-model to the current position and pass localized messages. Slides scroll and snap natively, so swiping works on touch devices.
Show a few highlights, such as product stages or testimonials, one at a time in limited space.
Show several cards at once with perView and let people step through them with arrows or dots. Use overlay placement when the cards should fill the viewport.
Rotate quotes every five seconds. A pause button is always shown, and rotation holds on hover and focus.
<script setup lang="ts">
import { ref } from 'vue'
import Carousel from './components/ui/carousel/Carousel.vue'
import CarouselItem from './components/ui/carousel/CarouselItem.vue'
const index = ref(0)
const quotes = [
'Setup took ten minutes.',
'The team adopted it in a week.',
'Support answered within the hour.',
]
const messages = {
label: 'Customer quotes',
previous: 'Previous quote',
next: 'Next quote',
slide: (n: number, total: number) => `Quote ${n} of ${total}`,
goTo: (n: number) => `Go to quote ${n}`,
pause: 'Pause quotes',
play: 'Play quotes',
roleDescription: 'carousel',
slideRoleDescription: 'slide',
}
</script>
<template>
<Carousel v-model="index" class="max-w-xl" :autoplay="5000" loop :messages="messages">
<CarouselItem v-for="quote in quotes" :key="quote">
<figure class="flex h-40 items-center justify-center rounded-xl bg-muted px-12 text-center">
<blockquote class="text-lg font-medium text-foreground">{{ quote }}</blockquote>
</figure>
</CarouselItem>
</Carousel>
</template>Use perView to show three slides; the dots count scroll positions. Overlay controls keep the arrows and picker over the cards.
<script setup lang="ts">
import { ref } from 'vue'
import Carousel from './components/ui/carousel/Carousel.vue'
import CarouselItem from './components/ui/carousel/CarouselItem.vue'
const index = ref(0)
const products = ['Aurora', 'Beacon', 'Cinder', 'Delta', 'Ember', 'Flux']
const messages = {
label: 'Products',
previous: 'Previous products',
next: 'Next products',
slide: (n: number, total: number) => `Product ${n} of ${total}`,
goTo: (n: number) => `Show products from ${n}`,
pause: 'Pause',
play: 'Play',
roleDescription: 'carousel',
slideRoleDescription: 'slide',
}
</script>
<template>
<Carousel
v-model="index"
class="max-w-2xl"
:per-view="3"
controls-placement="overlay"
:messages="messages"
>
<CarouselItem v-for="product in products" :key="product">
<div
class="flex h-40 items-start justify-center pt-4 rounded-xl border border-border bg-card font-medium text-card-foreground"
>
<span>{{ product }}</span>
</div>
</CarouselItem>
</Carousel>
</template>Set controls to false to hide both arrows and dots. The pause/play control stays available when autoplay is enabled.
<script setup lang="ts">
import { ref } from 'vue'
import Carousel from './components/ui/carousel/Carousel.vue'
import CarouselItem from './components/ui/carousel/CarouselItem.vue'
const index = ref(0)
const stories = ['A calmer start', 'A clearer plan', 'A stronger finish']
const messages = {
label: 'Project stories',
previous: 'Previous story',
next: 'Next story',
slide: (n: number, total: number) => `Story ${n} of ${total}`,
goTo: (n: number) => `Go to story ${n}`,
pause: 'Pause stories',
play: 'Play stories',
roleDescription: 'carousel',
slideRoleDescription: 'slide',
}
</script>
<template>
<Carousel
v-model="index"
class="max-w-xl"
:messages="messages"
:autoplay="5000"
loop
:controls="false"
>
<CarouselItem v-for="story in stories" :key="story">
<article
class="flex h-40 items-center justify-center rounded-xl border border-border bg-card p-6 text-center text-lg font-medium text-card-foreground"
>
{{ story }}
</article>
</CarouselItem>
</Carousel>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
autoplayprop | number | undefined | Not set | Milliseconds between automatic advances. Off when omitted or 0. |
perViewprop | number | undefined | 1 | Slides visible at once. |
loopprop | boolean | undefined | Not set | Wrap from the last position to the first, and the reverse. |
controlsprop | boolean | undefined | true | Show arrow and slide-picker controls. Autoplay controls remain available when enabled. |
controlsPlacementprop | "outside" | "overlay" | undefined | "outside" | Place navigation controls below the viewport or over the slides. |
messagesprop | CarouselMessages | Required | Supply the text this component displays for its built-in actions and states. |
modelValuemodel | number | undefined | 0 | Current value. Use v-model to keep it in sync with your page. |
update:modelValueevent | [value: number] | — | Requests a new model value from the parent. |
defaultslot | () => unknown | Required | Content shown inside Carousel. |
previousslot | ((props: { disabled: boolean; }) => unknown) | undefined | Optional | Content for the previous area of Carousel. |
nextslot | ((props: { disabled: boolean; }) => unknown) | undefined | Optional | Content for the next area of Carousel. |
pauseslot | (() => unknown) | undefined | Optional | Content for the pause area of Carousel. |
playslot | (() => unknown) | undefined | Optional | Content for the play area of Carousel. |
scrollToexposed | (index: number) => void | — | Access scroll to from a component template ref. |
nextexposed | () => void | — | Access next from a component template ref. |
prevexposed | () => void | — | Access prev from a component template ref. |
indexexposed | number | — | Access index from a component template ref. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | (() => unknown) | undefined | Optional | Content shown inside CarouselItem. |
// packages/frameworks/vue/components/carousel/types.ts
// ------- TYPES -------
export interface CarouselMessages {
/** Accessible name of the carousel region and its slide picker. */
label: string
previous: string
next: string
/** Name of one slide, for example `Slide 2 of 5`. */
slide: (index: number, total: number) => string
/** Name of one slide picker dot, for example `Go to slide 2`. */
goTo: (index: number) => string
pause: string
play: string
/** Localized `aria-roledescription` for the region; the attribute is omitted when absent. */
roleDescription?: string
/** Localized `aria-roledescription` for each slide; the attribute is omitted when absent. */
slideRoleDescription?: string
}
export interface CarouselProps {
/** Milliseconds between automatic advances. Off when omitted or 0. */
autoplay?: number
/** Slides visible at once. */
perView?: number
/** Wrap from the last position to the first, and the reverse. */
loop?: boolean
/** Show arrow and slide-picker controls. Autoplay controls remain available when enabled. */
controls?: boolean
/** Place navigation controls below the viewport or over the slides. */
controlsPlacement?: 'outside' | 'overlay'
messages: CarouselMessages
}