inbox
An animated inbox icon for React that draws its tray outline with a stroke-path animation on hover, built on motion/react. It exposes an imperative ref with startAnimation and stopAnimation so the animation can be triggered from code.
shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { InboxIcon } from "@/components/ui/inbox";export default function Example() { return <InboxIcon className="text-slate-700" size={24} />;}- Showing an inbox, mail, or messages entry in navigation bars, sidebars, or toolbars where a subtle hover animation adds polish.
- Signaling unread or incoming items in a notifications or activity area, triggered programmatically via the ref.
- Adding a playful micro-interaction to buttons or menu items that already have a hover state.
- Replacing a static inbox glyph in a React app that already uses motion/react and Tailwind-style className utilities.
Examples
Sidebar navigation item
Inbox icon used next to a label in a navigation link, inheriting text color so it follows the link state.
import { InboxIcon } from "@/components/ui/inbox";export function InboxNavItem() { return ( <a href="/inbox" className="flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground"> <InboxIcon size={20} /> <span>Inbox</span> </a> );}Programmatic animation via ref
Use the imperative handle to play the animation when new messages arrive, instead of relying on hover.
import { useRef } from "react";import { InboxIcon, type InboxIconHandle } from "@/components/ui/inbox";export function InboxButton({ hasNew }: { hasNew: boolean }) { const iconRef = useRef<InboxIconHandle>(null); return ( <button type="button" onClick={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} aria-label={hasNew ? "Inbox, new messages" : "Inbox"} > <InboxIcon ref={iconRef} size={24} /> </button> );}Custom hover handlers in controlled mode
When a ref is attached, onMouseEnter and onMouseLeave are forwarded to the provided callbacks instead of starting the built-in animation, so the caller takes over the behavior.
import { useRef } from "react";import { InboxIcon, type InboxIconHandle } from "@/components/ui/inbox";export function ControlledInbox() { const iconRef = useRef<InboxIconHandle>(null); return ( <InboxIcon ref={iconRef} size={28} onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} /> );}API reference
Accessibility
- The component renders a decorative SVG with no title or role; when the icon is the only content of an interactive element, provide an accessible name with aria-label on the button or link.
- Pass aria-hidden="true" on the icon when a visible text label already describes the control, so screen readers do not announce a duplicate.
- The animation is a purely visual hover effect and conveys no information on its own; do not rely on it to communicate state such as unread messages. Expose state in text or an aria-live region.
- Consider respecting prefers-reduced-motion by disabling startAnimation calls or hover handlers for users who request reduced motion.
- Because the icon is drawn with currentColor, ensure the surrounding text color meets contrast requirements against its background.
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 "inbox" component (heroicons-animated/inbox) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/inbox2. 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 { InboxIcon } from "@/components/ui/inbox";export default function Example() { return <InboxIcon className="text-slate-700" size={24} />;}```Files & dependencies
- inbox.tsx