Layered Stack
paceui-gsap/layered-stackFreeComponent
An interactive component that dynamically layers elements, creating a visually engaging stacked animation effect.
Live preview
live · rendered by the registry
Rendered by PaceUI GSAP on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://gsap.paceui.com/r/layered-stack.jsonSource
1"use client";23import { ComponentProps, useEffect, useRef } from "react";45import gsap from "gsap";67import { cn } from "@/lib/utils";89type LayeredStackProps = ComponentProps<"div"> & {};1011export const LayeredStack = ({ children, className, ...props }: LayeredStackProps) => {12 const containerRef = useRef<HTMLDivElement>(null);1314 const stackCards = () => {15 const container = containerRef.current;16 if (!container) return;1718 const cards = Array.from(container.children) as HTMLElement[];1920 cards.forEach((card, i) => {21 const left = card.offsetLeft;22 const top = card.offsetTop;23 const width = card.offsetWidth;24 const height = card.offsetHeight;2526 const offsetX = container.clientWidth / 2 - width / 2 - left;27 const offsetY = container.clientHeight / 2 - height / 2 - top;2829 gsap.to(card, {30 x: offsetX,31 y: offsetY,32 rotate: "random(-15,15)",33 zIndex: 100 - i,34 duration: 0.5,35 ease: "power2.out",36 overwrite: true,37 });38 });39 };4041 const resetCards = () => {42 const container = containerRef.current;43 if (!container) return;4445 const cards = Array.from(container.children);4647 gsap.to(cards, {48 x: 0,49 y: 0,50 zIndex: 1,51 duration: 0.6,52 rotate: 0,53 ease: "power3.out",54 stagger: {55 amount: 0.05,56 from: "start",57 },58 overwrite: true,59 });60 };6162 useEffect(() => {63 stackCards();64 }, []);6566 return (67 <div68 ref={containerRef}69 onMouseEnter={resetCards}70 onMouseLeave={stackCards}71 className={cn("relative", className)}72 {...props}>73 {children}74 </div>75 );76};
What it pulls in
npm packages
Files it writes
More from PaceUI GSAP
All 29 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Modal Ability Selectorai-modal-ability-selector | PaceUI GSAP | Components | Free | 2 deps | |
| Modal Selectorai-modal-selector | PaceUI GSAP | Components | Free | 2 deps | |
| Response Writerai-response-writer | PaceUI GSAP | Components | Free | 2 deps · 2 files | |
| AI Suggestionsai-suggestions | PaceUI GSAP | Components | Free | 2 deps | |
| Modal Ability Selectorai-token-counter | PaceUI GSAP | Components | Free | 2 deps | |
| Animated Stackanimated-stack | PaceUI GSAP | Components | Free | 2 deps | |
| Bouncing Textbouncing-text | PaceUI GSAP | Components | Free | 2 deps | |
| Dot Flowdot-flow | PaceUI GSAP | Components | Free | 2 deps |
