archive-box

An animated archive-box icon for React, built as a stroked SVG that lifts its lid and drops its body on hover. It is powered by motion and can also be driven programmatically through a ref.

archive-box
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @heroicons-animated/archive-box

Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { ArchiveBoxIcon } from "@/components/ui/archive-box";export function Example() {  return <ArchiveBoxIcon size={28} className="text-foreground" />;}
  • Use for archive, storage, or 'move to archive' actions in email, note, or file manager UIs
  • Use as a hover-animated decorative icon inside buttons, menu items, or sidebar navigation
  • Use when you need an icon that can be triggered programmatically (e.g. after a successful archive action) via its ref
  • Use when you want a lightweight, theme-aware line icon that scales with the surrounding font size through the size prop

Examples

Icon button with hover animation

Wraps the icon in a button so the hover animation signals an archive action.

icon-button-with-hover-animation.tsx
import { ArchiveBoxIcon } from "@/components/ui/archive-box";export function ArchiveButton() {  return (    <button      type="button"      aria-label="Archive message"      className="inline-flex size-9 items-center justify-center rounded-md hover:bg-accent"    >      <ArchiveBoxIcon size={20} />    </button>  );}

Programmatic control via ref

Uses the exported handle to start the animation after an async archive request resolves.

programmatic-control-via-ref.tsx
import { useRef } from "react";import { ArchiveBoxIcon, type ArchiveBoxIconHandle } from "@/components/ui/archive-box";export function ArchiveStatus() {  const iconRef = useRef<ArchiveBoxIconHandle>(null);  const handleArchive = async () => {    await new Promise((resolve) => setTimeout(resolve, 500));    iconRef.current?.startAnimation();  };  return (    <div className="flex items-center gap-2">      <ArchiveBoxIcon ref={iconRef} size={24} />      <button type="button" onClick={handleArchive}>        Archive      </button>    </div>  );}

Sidebar navigation item

Uses the icon inside a navigation link with a custom className for color and spacing.

sidebar-navigation-item.tsx
import { ArchiveBoxIcon } from "@/components/ui/archive-box";export function SidebarArchiveLink() {  return (    <a      href="/archive"      className="flex items-center gap-3 rounded-md px-3 py-2 text-sm text-muted-foreground hover:text-foreground"    >      <ArchiveBoxIcon size={18} className="shrink-0" />      <span>Archive</span>    </a>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. The viewBox stays 0 0 24 24, so the icon scales proportionally.
classNamestring—Additional class names applied to the wrapping div (passed through cn). The icon uses currentColor, so set text color via a text-* class.
onMouseEnter(event: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler on the wrapping div. When the ref handle is used (controlled mode), this is called instead of the built-in hover animation being triggered.
onMouseLeave(event: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler on the wrapping div. When the ref handle is used (controlled mode), this is called instead of the built-in reset animation being triggered.
refReact.Ref<ArchiveBoxIconHandle>—Forwarded ref exposing startAnimation() (plays the animated state) and stopAnimation() (returns to the normal state). Attaching it switches the icon into controlled mode, which disables automatic hover animation.
...propsHTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, data-*, onClick, etc.) are spread onto the wrapping div.

Accessibility

  • The SVG has no title or aria-label; when the icon conveys meaning on its own, add aria-label or a visible text label to the parent button or link.
  • When the icon is decorative (next to visible text), pass aria-hidden="true" through props so screen readers skip it.
  • The wrapping div is a generic container with no role; wrap the icon in a button or anchor so it is keyboard-focusable and announced with a name.
  • The hover animation is purely visual and communicates no state, so do not rely on it alone to convey information.
  • Respect reduced-motion preferences by disabling or shortening the animation in the parent if needed, since the motion animation runs regardless of the media query by default.

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.

prompt.md
Use the "archive-box" component (heroicons-animated/archive-box) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/archive-box2. 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 { ArchiveBoxIcon } from "@/components/ui/archive-box";export function Example() {  return <ArchiveBoxIcon size={28} className="text-foreground" />;}```

Files & dependencies

  • archive-box.tsx
dependenciesmotion

Looks similar, elsewhere