This component no longer exists. It was in ondo-ui’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-09 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
carousel
ondo-ui/carouselRemovedComponent
A carousel with motion and swipe built using Embla.
Install it
npx shadcn@latest add https://ui.ondo.dou.so/r/carousel.jsonSource
1"use client"23import * as React from "react"4import useEmblaCarousel, {5 type UseEmblaCarouselType,6} from "embla-carousel-react"78import { cn } from "@/lib/utils"9import { Button } from "@/components/ui/button"10import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react"1112type CarouselApi = UseEmblaCarouselType[1]13type UseCarouselParameters = Parameters<typeof useEmblaCarousel>14type CarouselOptions = UseCarouselParameters[0]15type CarouselPlugin = UseCarouselParameters[1]1617type CarouselProps = {18 opts?: CarouselOptions19 plugins?: CarouselPlugin20 orientation?: "horizontal" | "vertical"21 setApi?: (api: CarouselApi) => void22}2324type CarouselContextProps = {25 carouselRef: ReturnType<typeof useEmblaCarousel>[0]26 api: ReturnType<typeof useEmblaCarousel>[1]27 scrollPrev: () => void28 scrollNext: () => void29 canScrollPrev: boolean30 canScrollNext: boolean31} & CarouselProps3233const CarouselContext = React.createContext<CarouselContextProps | null>(null)3435function useCarousel() {36 const context = React.useContext(CarouselContext)3738 if (!context) {39 throw new Error("useCarousel must be used within a <Carousel />")40 }4142 return context43}4445function Carousel({46 orientation = "horizontal",47 opts,48 setApi,49 plugins,50 className,51 children,52 ...props53}: React.ComponentProps<"div"> & CarouselProps) {54 const [carouselRef, api] = useEmblaCarousel(55 {56 ...opts,57 axis: orientation === "horizontal" ? "x" : "y",58 },59 plugins60 )61 const [canScrollPrev, setCanScrollPrev] = React.useState(false)62 const [canScrollNext, setCanScrollNext] = React.useState(false)6364 const onSelect = React.useCallback((api: CarouselApi) => {65 if (!api) return66 setCanScrollPrev(api.canScrollPrev())67 setCanScrollNext(api.canScrollNext())68 }, [])6970 const scrollPrev = React.useCallback(() => {71 api?.scrollPrev()72 }, [api])7374 const scrollNext = React.useCallback(() => {75 api?.scrollNext()76 }, [api])7778 const handleKeyDown = React.useCallback(79 (event: React.KeyboardEvent<HTMLDivElement>) => {80 if (event.key === "ArrowLeft") {81 event.preventDefault()82 scrollPrev()83 } else if (event.key === "ArrowRight") {84 event.preventDefault()85 scrollNext()86 }87 },88 [scrollPrev, scrollNext]89 )9091 React.useEffect(() => {92 if (!api || !setApi) return93 setApi(api)94 }, [api, setApi])9596 React.useEffect(() => {97 if (!api) return98// … truncated
What it pulls in
npm packages
Other registry items
