carousel
shadcn-vue/carouselFreeComponent
shadcn-vue publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn-vue on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-vue.com/r/styles/new-york/carousel.jsonSource
1<script setup lang="ts">2import type { CarouselEmits, CarouselProps, WithClassAsProps } from "./interface"3import { cn } from "@/lib/utils"4import { useProvideCarousel } from "./useCarousel"56const props = withDefaults(defineProps<CarouselProps & WithClassAsProps>(), {7 orientation: "horizontal",8})910const emits = defineEmits<CarouselEmits>()1112const { canScrollNext, canScrollPrev, carouselApi, carouselRef, orientation, scrollNext, scrollPrev } = useProvideCarousel(props, emits)1314defineExpose({15 canScrollNext,16 canScrollPrev,17 carouselApi,18 carouselRef,19 orientation,20 scrollNext,21 scrollPrev,22})2324function onKeyDown(event: KeyboardEvent) {25 const prevKey = props.orientation === "vertical" ? "ArrowUp" : "ArrowLeft"26 const nextKey = props.orientation === "vertical" ? "ArrowDown" : "ArrowRight"2728 if (event.key === prevKey) {29 event.preventDefault()30 scrollPrev()3132 return33 }3435 if (event.key === nextKey) {36 event.preventDefault()37 scrollNext()38 }39}40</script>4142<template>43 <div44 :class="cn('relative', props.class)"45 role="region"46 aria-roledescription="carousel"47 tabindex="0"48 @keydown="onKeyDown"49 >50 <slot :can-scroll-next :can-scroll-prev :carousel-api :carousel-ref :orientation :scroll-next :scroll-prev />51 </div>52</template>
What it pulls in
npm packages
Other registry items
Files it writes
More from shadcn-vue
All 65 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn-vue | Components | Free | 2 deps · 5 files | |
| alertalert | shadcn-vue | Components | Free | no deps · 4 files | |
| alert-dialogalert-dialog | shadcn-vue | Components | Free | 2 deps · 10 files | |
| aspect-ratioaspect-ratio | shadcn-vue | Components | Free | 1 dep · 2 files | |
| attachmentattachment | shadcn-vue | Components | Free | 1 dep · 10 files | |
| avataravatar | shadcn-vue | Components | Free | 2 deps · 4 files | |
| badgebadge | shadcn-vue | Components | Free | 2 deps · 2 files | |
| breadcrumbbreadcrumb | shadcn-vue | Components | Free | 1 dep · 8 files |
