Css Box Non Uniform Demo
fancy/css-box-non-uniform-demoFreeBlock
A block component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/css-box-non-uniform-demo.jsonSource
1import { useEffect, useRef } from "react"23import { cn } from "@/lib/utils"4import CSSBox, { CSSBoxRef } from "@/components/fancy/blocks/css-box"56const BoxText = ({ className }: { className?: string }) => (7 <div8 className={cn(9 "w-full h-full text-white flex items-center justify-center p-2 text-sm font-bold bg-transparent",10 className11 )}12 >13 ANYTHING IS POSSIBLE14 </div>15)1617export default function CSSBox2Demo() {18 const boxRefs = useRef<(CSSBoxRef | null)[]>([])1920 useEffect(() => {21 const animate = async () => {22 const delay = (ms: number) =>23 new Promise((resolve) => setTimeout(resolve, ms))2425 while (true) {26 // Rotate to right face27 for (let i = 0; i < boxRefs.current.length; i++) {28 boxRefs.current[i]?.showRight()29 await delay(50)30 }31 await delay(1000)3233 // Rotate to back face34 for (let i = 0; i < boxRefs.current.length; i++) {35 boxRefs.current[i]?.showBack()36 await delay(50)37 }38 await delay(1000)3940 // Rotate to left face41 for (let i = 0; i < boxRefs.current.length; i++) {42 boxRefs.current[i]?.showLeft()43 await delay(50)44 }45 await delay(1000)4647 // Rotate to front face48 for (let i = 0; i < boxRefs.current.length; i++) {49 boxRefs.current[i]?.showFront()50 await delay(50)51 }52 await delay(1000)53 }54 }5556 animate()57 }, [])5859 return (60 <div className="flex flex-col items-center justify-center w-dvw h-dvh bg-black">61 <div>62 {[...Array(12)].map((_, index) => (63 <CSSBox64 key={index}65 ref={(el) => {66 if (el) boxRefs.current[index] = el67 }}68 width={200}69 height={30}70 depth={200}71 draggable={false}72 className="hover:z-10"73 faces={{74 front: <BoxText className=" border-white " />,75 back: <BoxText className=" border-white" />,76 left: <BoxText className=" border-white bg-white text-black" />,77 right: <BoxText className=" border-white bg-white text-black" />,78 }}79 />80 ))}81 </div>82 </div>83 )84}
What it pulls in
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 Demobox-carousel-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 |
