Trên trang này

Trang này chưa có bản tiếng Việt, nội dung bên dưới là bản tiếng Anh. Xem trang tiếng Anh

Carousel

Install, props and the parts Carousel is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):

npx shadcn-vue@latest add https://beehexa.design/r/carousel.json

This also installs Button and embla-carousel-vue.

Use

<script setup lang="ts">
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from '@/components/ui/carousel'

const tips = ['Map your fields', 'Test with one order', 'Watch the first day']
</script>

<template>
  <div class="px-12">
    <Carousel aria-label="Getting started tips">
      <CarouselContent>
        <CarouselItem v-for="(tip, index) in tips" :key="tip" :aria-label="`${index + 1} of ${tips.length}`">
          {{ tip }}
        </CarouselItem>
      </CarouselContent>
      <CarouselPrevious />
      <CarouselNext />
    </Carousel>
  </div>
</template>

Props

Part Prop Values Notes
Carousel orientation horizontal (default), vertical Also sets which arrow keys move
Carousel opts Embla options Such as { align: 'start', loop: true }
Carousel plugins Embla plugins Such as autoplay; see Usage before turning it on
Carousel @init-api event Gives the Embla API, for a slide counter or dots
CarouselPrevious, CarouselNext variant, size Button variants and sizes Default outline and icon-sm. The slot replaces the icon and the hidden label
CarouselItem class string Set the basis for several slides in view

useCarousel() gives scrollPrev, scrollNext, canScrollPrev, canScrollNext and the API inside a carousel.

Built on

embla-carousel-vue, with the shadcn-vue Carousel API and the Beehexa Button. Beehexa adds the focus ring on the carousel, the token gaps and round buttons.