Box Carousel
fancy/box-carouselFreeComponent
A ui component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/box-carousel.jsonSource
1"use client"23import React, {4 forwardRef,5 memo,6 ReactNode,7 useCallback,8 useEffect,9 useImperativeHandle,10 useMemo,11 useRef,12 useState,13} from "react"14import {15 animate,16 motion,17 useMotionValue,18 useReducedMotion,19 useSpring,20 useTransform,21 ValueAnimationOptions,22} from "motion/react"2324import { cn } from "@/lib/utils"2526interface CarouselItem {27 /**28 * Unique identifier for the carousel item29 */30 id: string31 /**32 * The type of media: "image" or "video"33 */34 type: "image" | "video"35 /**36 * Source URL for the image or video37 */38 src: string39 /**40 * (Optional) Alternative text for images41 */42 alt?: string43 /**44 * (Optional) Poster image for videos (displayed before playback)45 */46 poster?: string47}4849/**50 * Props for a single face of the cube in the BoxCarousel.51 */52interface FaceProps {53 /**54 * The CSS transform string to position and rotate the face in 3D space.55 */56 transform: string57 /**58 * Optional additional CSS class names for the face.59 */60 className?: string61 /**62 * Optional React children to render inside the face.63 */64 children?: ReactNode65 /**66 * Optional inline styles for the face.67 */68 style?: React.CSSProperties69 /**70 * If true, enables debug mode (e.g., shows backface and opacity).71 */72 debug?: boolean73}7475const CubeFace = memo(76 ({ transform, className, children, style, debug }: FaceProps) => (77 <div78 className={cn(79 "absolute overflow-hidden",80 debug && "backface-visible opacity-50",81 className82 )}83 style={{ transform, ...style }}84 >85 {children}86 </div>87 )88)8990CubeFace.displayName = "CubeFace"9192const MediaRenderer = memo(93 ({94 item,95 className,96 debug = false,97 }: {98 item: CarouselItem99 className?: string100 debug?: boolean101 }) => {102 if (!debug) {103 if (item.type === "video") {104 return (105 <video106 src={item.src}107 poster={item.poster}108 className={cn("w-full h-full object-cover", className)}109 muted110 loop111 autoPlay112 />113 )114 }115116 return (117 <img118 src={item.src}119 alt={item.alt || ""}120 draggable={false}121 className={cn("w-full h-full object-cover", className)}122 />123 )124 }125126 return (127 <div128 className={cn(129 "w-full h-full flex items-center justify-center border text-2xl",130 className131 )}132 >133// … truncated
What it pulls in
npm packages
Files it writes
More from fancy
All 158 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradient With Svganimated-gradient-with-svg | fancy | Components | Free | no deps | |
| Basic Number Tickerbasic-number-ticker | fancy | Components | Free | 1 dep | |
| Breathing Textbreathing-text | fancy | Components | Free | 1 dep | |
| Circling Elementscircling-elements | fancy | Components | Free | 1 dep | |
| Css Boxcss-box | fancy | Components | Free | 1 dep | |
| Cursor Attractor And Gravitycursor-attractor-and-gravity | fancy | Components | Free | 5 deps | |
| Drag Elementsdrag-elements | fancy | Components | Free | 1 dep | |
| Elastic Lineelastic-line | fancy | Components | Free | 1 dep |
