Layers
LayersIcon is an animated stacked-layers icon built on motion/react that plays a spring bounce on hover, or on demand through a ref handle. It renders an inline SVG with the Lucide layers glyph, sized by a size prop.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Usage
import { LayersIcon } from "@/components/ui/layers";export function Example() { return <LayersIcon />;}- Use as an animated icon for layers, stacks, collections, or grouping features in a toolbar, sidebar, or menu item.
- Use for hover-triggered micro-interactions on cards, buttons, or navigation links where a subtle spring motion adds feedback.
- Use when you need to start the animation programmatically (for example, when a panel opens) by holding a ref to LayersIconHandle.
- Avoid it where a static icon is required or where motion should be reduced for users who prefer less animation.
Examples
Hover-animated icon in a navigation link
Uses the default hover behavior with no ref. Hovering the wrapper div plays the spring sequence and returns to the rest state on leave.
import { LayersIcon } from "@/components/ui/layers";export function SidebarCollectionsLink() { return ( <a href="/collections" className="flex items-center gap-2 text-sm font-medium"> <LayersIcon size={20} className="text-blue-600" /> Collections </a> );}Programmatic control via ref
Attaches a ref typed as LayersIconHandle. Calling startAnimation or stopAnimation disables the built-in hover animation and drives the animation from the parent.
import { useRef } from "react";import { LayersIcon, type LayersIconHandle } from "@/components/ui/layers";export function ExpandButton() { const iconRef = useRef<LayersIconHandle>(null); return ( <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2" onClick={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} > <LayersIcon ref={iconRef} size={18} /> Show layers </button> );}Custom hover handlers in controlled mode
When a ref is attached, the component delegates mouse enter and leave to the onMouseEnter and onMouseLeave props you pass, so you can add your own logic while the animation is driven through the handle.
import { useRef } from "react";import { LayersIcon, type LayersIconHandle } from "@/components/ui/layers";export function LayersCard() { const iconRef = useRef<LayersIconHandle>(null); return ( <div className="rounded-lg border p-4 hover:bg-muted" onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} > <LayersIcon ref={iconRef} size={32} className="text-foreground" /> </div> );}API reference
Accessibility
- The SVG has no title, aria-label, or role, and the outer div has no role. If the icon is purely decorative, keep it as is or add aria-hidden="true" to the wrapper using the rest props.
- If the icon conveys meaning on its own (no adjacent text), wrap it with role="img" and an aria-label such as "Layers" on the outer element, or place it in a labeled button.
- Inside an interactive element, make sure the parent has an accessible name, since the icon itself is not focusable and contributes no text.
- The animation is a short spring motion with no looping. Respect prefers-reduced-motion by passing a ref and controlling startAnimation yourself, or by skipping the call when the user prefers reduced motion.
- Hover-only animation does not run on touch or keyboard focus. Pair it with visible text or a state change so the meaning does not depend on the hover animation.
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 "Layers" component (lucide-animated/layers) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/layers.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.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { LayersIcon } from "@/components/ui/layers";export function Example() { return <LayersIcon />;}```Files & dependencies
- layers.tsx