mail-open

An animated mail-open icon for shadcn/ui that plays a short envelope-opening sequence: the flap lifts and a letter slides out of the envelope. It renders an SVG wrapped in a div and is driven by motion/react, with playback triggered on hover or through an imperative ref.

mail-open
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 @hugeicons-animated/mail-open

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

Usage

usage.tsx
import { MailOpenIcon } from '@/icons/mail-open';export function Example() {  return <MailOpenIcon size={28} className="text-foreground" />;}
  • Use for mail, inbox, or message-opened states such as read receipts, notification badges, or 'message opened' confirmations.
  • Use as a decorative or interactive hover icon in navigation, sidebars, or toolbars where a subtle animated affordance adds delight.
  • Use as a status indicator that replays on demand via the ref handle, for example after a successful email send or when an inbox is refreshed.
  • Avoid for purely static contexts or where motion must be minimal, since the icon does not expose a dedicated pause control beyond the reduced-motion check.

Examples

Basic hover icon

Renders the icon at its default size. The animation plays when the pointer enters the icon.

basic-hover-icon.tsx
import { MailOpenIcon } from '@/icons/mail-open';export default function InboxLink() {  return (    <a href="/inbox" className="inline-flex items-center gap-2">      <MailOpenIcon size={24} className="text-zinc-700 dark:text-zinc-200" />      <span>Inbox</span>    </a>  );}

Programmatic playback via ref

Uses the MailOpenIconHandle exposed through forwardRef to play the animation when an action completes.

programmatic-playback-via-ref.tsx
import { useRef } from 'react';import { Button } from '@/components/ui/button';import { MailOpenIcon, type MailOpenIconHandle } from '@/icons/mail-open';export default function SendConfirmation() {  const iconRef = useRef<MailOpenIconHandle>(null);  return (    <Button variant="outline" onClick={() => iconRef.current?.startAnimation()}>      <MailOpenIcon ref={iconRef} size={20} />      Mark as opened    </Button>  );}

Notification badge with larger icon

Shows the icon at a larger size inside a notification row, with a custom mouse-enter handler forwarded to the wrapper div.

notification-badge-with-larger-icon.tsx
import { MailOpenIcon } from '@/icons/mail-open';export default function NotificationRow() {  return (    <div className="flex items-center gap-3 rounded-md p-3 hover:bg-zinc-100">      <MailOpenIcon        size={32}        className="shrink-0 text-blue-600"        onMouseEnter={() => console.log('mail icon hovered')}      />      <p className="text-sm">You have 3 unread messages</p>    </div>  );}

Sidebar navigation item

Uses the icon as a sidebar entry with aria-hidden decoration and a visible text label.

sidebar-navigation-item.tsx
import { MailOpenIcon } from '@/icons/mail-open';export default function SidebarMailItem() {  return (    <li>      <button type="button" className="flex w-full items-center gap-2 px-3 py-2">        <MailOpenIcon size={18} aria-hidden="true" />        <span>Messages</span>      </button>    </li>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels. The viewBox is always 0 0 24 24.
classNamestring—Class name applied to the outer wrapping div (passed through cn).
onMouseEnterMouseEventHandler<HTMLDivElement>—Called when the pointer enters the wrapper div, before the built-in animation starts. Inherited from HTMLAttributes<HTMLDivElement>.
onMouseLeaveMouseEventHandler<HTMLDivElement>—Called when the pointer leaves the wrapper div. Inherited from HTMLAttributes<HTMLDivElement>. Because loops is false, leaving does not reset the animation.
refRef<MailOpenIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation() on the MailOpenIconHandle. Note that the ref targets the handle, not the DOM div. Calling startAnimation() plays the sequence once; it is a no-op when reduced motion is preferred or while a run is in progress. stopAnimation() has no effect for this icon because looping is disabled.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, role, data-*, etc.) are spread onto the wrapper div.

Accessibility

  • The SVG has no title, desc, or role. When the icon conveys meaning, wrap it in an element with an accessible name, or pass aria-label or aria-hidden="true" on the wrapper div for decorative use.
  • Respects the user's prefers-reduced-motion setting through useReducedMotion; the animation does not start when reduced motion is requested.
  • Playback is triggered by pointer hover only in the default setup, so keyboard and touch users will not see the animation. Pair it with a focusable control or a text label that conveys the same state.
  • The icon uses currentColor for strokes, so it keeps sufficient contrast when the parent text color meets WCAG requirements.
  • Because the envelope and letter animate in place, avoid placing it where its motion could be mistaken for a loading indicator.

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 "mail-open" component (hugeicons-animated/mail-open) from its shadcn registry.1. Install it with: npx shadcn@latest add @hugeicons-animated/mail-open2. 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, ...HTMLAttributes<HTMLDivElement>.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { MailOpenIcon } from '@/icons/mail-open';export function Example() {  return <MailOpenIcon size={28} className="text-foreground" />;}```

Files & dependencies

  • icons/mail-open.tsx
  • lib/use-icon-animation.ts
dependenciesmotion

Looks similar, elsewhere