Home / File/ carousel.tsx — ui Source File

carousel.tsx — ui Source File

Architecture documentation for carousel.tsx, a tsx file in the ui codebase. 5 imports, 0 dependents.

File tsx ComponentRegistry UIPrimitives 5 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  736f7ee1_27b9_e9b5_e0f3_5ccbcfe0a0bf["carousel.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  736f7ee1_27b9_e9b5_e0f3_5ccbcfe0a0bf --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  559b74d2_d779_7211_a405_2fab8e345935["embla-carousel-react"]
  736f7ee1_27b9_e9b5_e0f3_5ccbcfe0a0bf --> 559b74d2_d779_7211_a405_2fab8e345935
  8ad666ec_1b20_adda_0392_87a60bdb3a68["utils"]
  736f7ee1_27b9_e9b5_e0f3_5ccbcfe0a0bf --> 8ad666ec_1b20_adda_0392_87a60bdb3a68
  7328fa0a_98b6_fe77_42fd_0d1582b24604["button"]
  736f7ee1_27b9_e9b5_e0f3_5ccbcfe0a0bf --> 7328fa0a_98b6_fe77_42fd_0d1582b24604
  de6fac54_74ca_6c25_8f8b_d1ba3287dbf2["icon-placeholder"]
  736f7ee1_27b9_e9b5_e0f3_5ccbcfe0a0bf --> de6fac54_74ca_6c25_8f8b_d1ba3287dbf2
  style 736f7ee1_27b9_e9b5_e0f3_5ccbcfe0a0bf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import useEmblaCarousel, {
  type UseEmblaCarouselType,
} from "embla-carousel-react"

import { cn } from "@/registry/bases/base/lib/utils"
import { Button } from "@/registry/bases/base/ui/button"
import { IconPlaceholder } from "@/app/(create)/components/icon-placeholder"

type CarouselApi = UseEmblaCarouselType[1]
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
type CarouselOptions = UseCarouselParameters[0]
type CarouselPlugin = UseCarouselParameters[1]

type CarouselProps = {
  opts?: CarouselOptions
  plugins?: CarouselPlugin
  orientation?: "horizontal" | "vertical"
  setApi?: (api: CarouselApi) => void
}

type CarouselContextProps = {
  carouselRef: ReturnType<typeof useEmblaCarousel>[0]
  api: ReturnType<typeof useEmblaCarousel>[1]
  scrollPrev: () => void
  scrollNext: () => void
  canScrollPrev: boolean
  canScrollNext: boolean
} & CarouselProps

const CarouselContext = React.createContext<CarouselContextProps | null>(null)

function useCarousel() {
  const context = React.useContext(CarouselContext)

  if (!context) {
    throw new Error("useCarousel must be used within a <Carousel />")
  }

  return context
}

function Carousel({
  orientation = "horizontal",
  opts,
  setApi,
  plugins,
  className,
  children,
  ...props
}: React.ComponentProps<"div"> & CarouselProps) {
  const [carouselRef, api] = useEmblaCarousel(
    {
      ...opts,
      axis: orientation === "horizontal" ? "x" : "y",
    },
    plugins
  )
// ... (197 more lines)

Subdomains

Dependencies

  • button
  • embla-carousel-react
  • icon-placeholder
  • react
  • utils

Frequently Asked Questions

What does carousel.tsx do?
carousel.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, UIPrimitives subdomain.
What functions are defined in carousel.tsx?
carousel.tsx defines 7 function(s): Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, api, useCarousel.
What does carousel.tsx depend on?
carousel.tsx imports 5 module(s): button, embla-carousel-react, icon-placeholder, react, utils.
Where is carousel.tsx in the architecture?
carousel.tsx is located at apps/v4/registry/bases/base/ui/carousel.tsx (domain: ComponentRegistry, subdomain: UIPrimitives, directory: apps/v4/registry/bases/base/ui).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free