document-plus

An animated document icon with a plus sign for React that draws a vertical and a horizontal stroke into a document outline on hover. It is built on motion/react and can also be triggered imperatively through a ref.

document-plus
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/document-plus

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

Usage

usage.tsx
import { DocumentPlusIcon } from "@/components/ui/document-plus";<DocumentPlusIcon />
  • Create or add-document actions such as a New document button, menu item, or toolbar entry where a playful hover animation adds emphasis
  • Empty states or onboarding cards that need a lightweight animated illustration of creating a file
  • Controlling the animation from a parent (for example, when a whole button or row is hovered) via the ref handle
  • Replacing a static document-plus icon with an animated variant that matches the rest of the heroicons-animated set

Examples

Hover-triggered icon in a menu item

The icon animates when the pointer enters its own wrapper element. No ref is needed.

hover-triggered-icon-in-a-menu-item.tsx
import { DocumentPlusIcon } from "@/components/ui/document-plus";export function NewDocumentMenuItem() {  return (    <button      type="button"      className="flex items-center gap-2 rounded-md px-3 py-2 text-sm hover:bg-accent"    >      <DocumentPlusIcon size={18} />      New document    </button>  );}

Parent-controlled animation via ref

Attaching a ref switches the icon to controlled mode. Hover on the button drives startAnimation and stopAnimation on the icon.

parent-controlled-animation-via-ref.tsx
"use client";import { useRef } from "react";import { DocumentPlusIcon, type DocumentPlusIconHandle } from "@/components/ui/document-plus";export function CreateButton() {  const iconRef = useRef<DocumentPlusIconHandle>(null);  return (    <button      type="button"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}      className="inline-flex items-center gap-2 rounded-md border px-4 py-2"    >      <DocumentPlusIcon ref={iconRef} size={20} />      Create    </button>  );}

Larger icon as a labelled link

A bigger size with a className on the wrapper, placed inside a link that has an accessible name.

larger-icon-as-a-labelled-link.tsx
import { DocumentPlusIcon } from "@/components/ui/document-plus";export function NewDocumentLink() {  return (    <a      href="/documents/new"      aria-label="Create new document"      className="inline-flex text-blue-600 hover:text-blue-700"    >      <DocumentPlusIcon size={32} className="cursor-pointer" />    </a>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered svg in pixels. Applied to both the width and height attributes.
classNamestring—Class names applied to the outer wrapper div through cn(). The svg itself is sized by size, so use className for layout and color (text color drives stroke via currentColor).
refReact.Ref<DocumentPlusIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation(). Attaching a ref switches the component to controlled mode: the internal hover handlers stop starting animations, and the onMouseEnter and onMouseLeave props are called instead.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Called on pointer enter only when the ref is attached (controlled mode). In uncontrolled mode this prop is not invoked and the icon animates on its own.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Called on pointer leave only when the ref is attached (controlled mode). In uncontrolled mode this prop is not invoked and the icon returns to its rest state on its own.
...rest (HTMLAttributes<HTMLDivElement>)React.HTMLAttributes<HTMLDivElement>—All other standard div attributes such as id, style, aria-*, data-*, and event handlers, spread onto the outer wrapper div.

Accessibility

  • The svg has no role, title, or aria-label. The icon is decorative by default, so when it appears next to visible text, keep it as is and let the text provide the name.
  • When the icon is the only content of a control, give the interactive parent an accessible name (for example, aria-label on a button or link). Passing aria-label through the props applies it to the wrapper div, which has no role, so pair it with role="img" when the icon itself must be announced.
  • The animation is pure motion with no text alternative. It conveys no information that is not also available in the label, so it should not be the only signal of state.
  • The source does not check the prefers-reduced-motion media query. If reduced motion matters for your product, wrap usage or disable the hover trigger in your own code.
  • Hover-only animation has no keyboard equivalent. Do not rely on it to communicate that an element is focusable or actionable.

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 "document-plus" component (heroicons-animated/document-plus) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/document-plus2. 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, ref, onMouseEnter, onMouseLeave, ...rest (HTMLAttributes<HTMLDivElement>).Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { DocumentPlusIcon } from "@/components/ui/document-plus";<DocumentPlusIcon />```

Files & dependencies

  • document-plus.tsx
dependenciesmotion

Looks similar, elsewhere