Square Stack
SquareStackIcon is an animated Lucide-style square-stack icon built with motion/react. Hovering it, or calling its imperative startAnimation and stopAnimation methods through a ref, makes the small bottom-right square pulse and the two stacked outline cards shrink slightly.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { SquareStackIcon } from "@/components/ui/square-stack";export function Example() { return <SquareStackIcon className="text-foreground" size={28} />;}- Use it as a clickable or hover-triggered icon for stacked content, layers, collections, or library and deck views in navigation, toolbars, or sidebars.
- Use it inside buttons or menu items where a subtle hover micro-interaction adds polish without distracting from the label.
- Use the ref API when a parent component needs to start or stop the animation, for example when a row is selected or a loading state begins.
- Avoid it where motion must be reduced or where the icon alone must convey a status that changes on hover.
Examples
Hover-triggered icon inside a button
The icon animates on hover through its built-in mouse handlers. The className is applied to the wrapper div, and size controls the SVG dimensions.
import { SquareStackIcon } from "@/components/ui/square-stack";export function LibraryButton() { return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm"> <SquareStackIcon className="text-primary" size={20} /> Collections </button> );}Controlled animation via ref
Passing a ref switches the component to controlled mode. Mouse events then call the onMouseEnter and onMouseLeave props instead of playing the animation, so the parent drives it with startAnimation and stopAnimation.
import { useRef } from "react";import { SquareStackIcon, type SquareStackIconHandle } from "@/components/ui/square-stack";export function SyncRow() { const iconRef = useRef<SquareStackIconHandle>(null); return ( <div onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} className="flex items-center gap-2" > <SquareStackIcon ref={iconRef} size={24} /> <span>Sync stack</span> </div> );}Menu item with a looping status indicator
A parent can start the animation when a background job begins and stop it when the job completes. The component is used as a sidebar navigation icon.
import { useEffect, useRef } from "react";import { SquareStackIcon, type SquareStackIconHandle } from "@/components/ui/square-stack";type Props = { busy: boolean };export function StackNavItem({ busy }: Props) { const ref = useRef<SquareStackIconHandle>(null); useEffect(() => { if (busy) ref.current?.startAnimation(); else ref.current?.stopAnimation(); }, [busy]); return ( <a href="/stacks" className="flex items-center gap-2 text-sm"> <SquareStackIcon ref={ref} size={18} /> Stacks </a> );}API reference
Accessibility
- The SVG has no title, desc, or aria-label. When the icon conveys meaning on its own, add aria-label to the wrapper div or wrap it in a labelled button, for example aria-label="Stacks".
- If the icon is decorative because adjacent text already labels the control, add aria-hidden="true" through props so screen readers skip it.
- Hover-only animation gives no feedback to keyboard or touch users. Make sure the same action is reachable through focus and click, and do not rely on the animation to communicate state.
- Respect prefers-reduced-motion. The component does not check this media query itself, so wrap the trigger in a condition or disable the ref calls for users who prefer reduced motion.
- The wrapper div is not focusable by default. If the icon acts as a control, place it inside a button or link, or add role and tabIndex through props.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Square Stack" component (lucide-animated/square-stack) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/square-stack.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: size, className, onMouseEnter, onMouseLeave, ref, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { SquareStackIcon } from "@/components/ui/square-stack";export function Example() { return <SquareStackIcon className="text-foreground" size={28} />;}```Files & dependencies
- square-stack.tsx