Box Carousel Demo
fancy/box-carousel-demoFreeBlock
A block component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/box-carousel-demo.jsonSource
1"use client"23import { useRef, useState } from "react"4import { Bug, BugOff } from "lucide-react"5import BoxCarousel, {6 type BoxCarouselRef,7 type CarouselItem,8} from "@/components/fancy/carousel/box-carousel"9import useScreenSize from "@/hooks/use-screen-size"1011// Sample carousel items with mix of images and videos12const carouselItems: CarouselItem[] = [13 {14 id: "1",15 type: "image",16 src: "https://cdn.cosmos.so/778d0640-d4b8-45b4-8bbe-862e759c231d?format=jpeg",17 alt: "Blurry poster"18 },19 {20 id: "2",21 type: "image",22 src: "https://cdn.cosmos.so/27ac2696-1f2b-498e-8d3d-11f2dd358ab9?format=jpeg",23 alt: "Abstract blurry figure"24 },25 {26 id: "3",27 type: "image",28 src: "https://cdn.cosmos.so/c48b739d-202d-4340-ab6b-afa34f0d7142?format=jpeg",29 alt: "Long exposure photo of a person"30 },31 {32 id: "4",33 type: "image",34 src: "https://cdn.cosmos.so/5332f9ac-7823-4635-871d-d4b3032e1c62?format=jpeg",35 alt: "Blurry portrait photo of a person"36 },37 {38 id: "5",39 type: "image",40 src: "https://cdn.cosmos.so/d9ed937e-7c3b-4f64-a4f3-708d639f13a1?format=jpeg",41 alt: "Long exposure shots with multiple people"42 },43 {44 id: "6",45 type: "image",46 src: "https://cdn.cosmos.so/33b43e2a-da66-42d9-a0b1-08165d80b0aa?format=jpeg",47 alt: "Close up blurry photo of a person poster"48 },49 {50 id: "7",51 type: "image",52 src: "https://cdn.cosmos.so/40342df7-2ea2-4297-add2-fe17cdc62551?format=jpeg",53 alt: "Long exposure shot of a motorcyclist"54 },55]5657export default function BoxCarouselDemo() {58 const carouselRef = useRef<BoxCarouselRef>(null)59 const [debug, setDebug] = useState(false)60 const screenSize = useScreenSize()6162 // Responsive dimensions based on screen size63 const getCarouselDimensions = () => {64 if (screenSize.lessThan("md")) {65 return { width: 200, height: 150 }66 }67 return { width: 350, height: 250 }68 }6970 const { width, height } = getCarouselDimensions()7172 const handleNext = () => {73 carouselRef.current?.next()74 }7576 const handlePrev = () => {77 carouselRef.current?.prev()78 }7980 const handleIndexChange = (index: number) => {81 console.log('Index changed:', index)82 }8384 const toggleDebug = () => {85 setDebug(!debug)86 }8788 return (89 <div className="w-full max-w-4xl h-full p-6 flex justify-items-center justify-center items-center text-muted-foreground bg-[#fefefe]">90 <button91 onClick={toggleDebug}92// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from fancy
All 158 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradient Demoanimated-gradient-demo | fancy | Blocks | Free | no deps | |
| Basic Number Ticker Demobasic-number-ticker-demo | fancy | Blocks | Free | no deps | |
| Box Carousel Autoplay Demobox-carousel-autoplay-demo | fancy | Blocks | Free | 1 dep | |
| Box Carousel Video Demobox-carousel-video-demo | fancy | Blocks | Free | 1 dep | |
| Breathing Text Demobreathing-text-demo | fancy | Blocks | Free | no deps | |
| Circling Elements Democircling-elements-demo | fancy | Blocks | Free | no deps | |
| Circling Elements Easing Democircling-elements-easing-demo | fancy | Blocks | Free | no deps | |
| Css Box Democss-box-demo | fancy | Blocks | Free | no deps |
