Carousel() — ui Function Reference
Architecture documentation for the Carousel() function in carousel.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 32c3ee71_e4c7_eb32_e592_59cfb179e8e5["Carousel()"] 6e062cf6_8484_b47c_befe_53e1b99f8534["carousel.tsx"] 32c3ee71_e4c7_eb32_e592_59cfb179e8e5 -->|defined in| 6e062cf6_8484_b47c_befe_53e1b99f8534 style 32c3ee71_e4c7_eb32_e592_59cfb179e8e5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
deprecated/www/registry/default/ui/carousel.tsx lines 49–149
(
{
orientation = "horizontal",
opts,
setApi,
plugins,
className,
children,
...props
},
ref
) => {
const [carouselRef, api] = useEmblaCarousel(
{
...opts,
axis: orientation === "horizontal" ? "x" : "y",
},
plugins
)
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
const [canScrollNext, setCanScrollNext] = React.useState(false)
const onSelect = React.useCallback((api: CarouselApi) => {
if (!api) {
return
}
setCanScrollPrev(api.canScrollPrev())
setCanScrollNext(api.canScrollNext())
}, [])
const scrollPrev = React.useCallback(() => {
api?.scrollPrev()
}, [api])
const scrollNext = React.useCallback(() => {
api?.scrollNext()
}, [api])
const handleKeyDown = React.useCallback(
(event: React.KeyboardEvent<HTMLDivElement>) => {
if (event.key === "ArrowLeft") {
event.preventDefault()
scrollPrev()
} else if (event.key === "ArrowRight") {
event.preventDefault()
scrollNext()
}
},
[scrollPrev, scrollNext]
)
React.useEffect(() => {
if (!api || !setApi) {
return
}
setApi(api)
}, [api, setApi])
React.useEffect(() => {
if (!api) {
return
}
onSelect(api)
api.on("reInit", onSelect)
api.on("select", onSelect)
return () => {
api?.off("select", onSelect)
}
}, [api, onSelect])
return (
<CarouselContext.Provider
value={{
carouselRef,
api: api,
opts,
orientation:
Domain
Subdomains
Source
Frequently Asked Questions
What does Carousel() do?
Carousel() is a function in the ui codebase, defined in deprecated/www/registry/default/ui/carousel.tsx.
Where is Carousel() defined?
Carousel() is defined in deprecated/www/registry/default/ui/carousel.tsx at line 49.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free