arrow-down-on-square

An animated outline arrow-down-on-square icon for React that bounces its down arrow when hovered. It can also be controlled imperatively through a ref with startAnimation and stopAnimation.

arrow-down-on-square
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/arrow-down-on-square

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

Usage

usage.tsx
import { ArrowDownOnSquareIcon } from '@/components/ui/arrow-down-on-square'; export default function Example() { return <ArrowDownOnSquareIcon className='text-neutral-700' size={28} />; }
  • Download, save-to-device, or export actions where the icon should signal a file being saved into a container
  • Toolbar or menu buttons that need a subtle hover micro-interaction without a heavy animation
  • Interactive UI where a parent component should trigger the arrow animation programmatically through a ref
  • Replacing a static download-style icon with a lightweight animated version that inherits text color

Examples

Hover-animated icon button

Uses the default uncontrolled hover behavior inside a plain button. The arrow bounces on hover without any extra wiring.

hover-animated-icon-button.tsx
import { ArrowDownOnSquareIcon } from '@/components/ui/arrow-down-on-square'; export default function DownloadButton() { return <button type='button' aria-label='Download file' className='inline-flex items-center justify-center rounded-md p-2 hover:bg-neutral-100'><ArrowDownOnSquareIcon size={24} /></button>; }

Programmatic control via ref

Attaches a ref to trigger the animation from a click handler. Once a ref is attached, the component stops animating on hover and defers to the onMouseEnter and onMouseLeave props you pass.

programmatic-control-via-ref.tsx
'use client'; import { useRef } from 'react'; import { ArrowDownOnSquareIcon, type ArrowDownOnSquareIconHandle } from '@/components/ui/arrow-down-on-square'; export default function SaveAction() { const iconRef = useRef<ArrowDownOnSquareIconHandle>(null); return <button type='button' aria-label='Save' onClick={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} className='p-2'><ArrowDownOnSquareIcon ref={iconRef} size={28} /></button>; }

Larger icon with custom color in a menu item

Shows the icon in a menu row with a larger size and a color set through a Tailwind class on the wrapper.

larger-icon-with-custom-color-in-a-menu-item.tsx
import { ArrowDownOnSquareIcon } from '@/components/ui/arrow-down-on-square'; export default function MenuItem() { return <div className='flex items-center gap-3 text-blue-600'><ArrowDownOnSquareIcon size={32} /><span className='text-sm font-medium'>Export as PDF</span></div>; }

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 div wrapper, passed through the cn utility. Use it to set color, margin, or layout.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler. When the ref is attached (controlled mode), this is called instead of the built-in hover animation. Otherwise it is called in addition to nothing else, since the built-in animation runs only in uncontrolled mode.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler. When the ref is attached (controlled mode), this is called instead of resetting the animation. Otherwise the built-in animation resets and this handler is not called.
refReact.Ref<ArrowDownOnSquareIconHandle>—Forwarded ref exposing startAnimation() to play the arrow bounce and stopAnimation() to return the arrow to its resting position. Attaching a ref switches the component into controlled mode.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes such as id, style, aria-*, role, and event handlers are spread onto the outer wrapper div.

Accessibility

  • The rendered SVG has no title or aria-label, so screen readers may ignore it. Wrap the icon in a button or link with an aria-label such as 'Download' or 'Save'.
  • If the icon is purely decorative next to visible text, add aria-hidden='true' through the spread HTML attributes to avoid redundant announcements.
  • The hover animation is a transform on a single path, and it does not change layout. Consider respecting prefers-reduced-motion by avoiding startAnimation calls or by disabling the animation in your wrapper when the user prefers reduced motion.
  • Because the animation is hover-only in default mode, keyboard users do not see it. Call startAnimation on focus or on keyboard activation through the ref to provide equivalent feedback.
  • Color follows currentColor, so ensure the stroke contrast against the background meets WCAG non-text contrast of 3:1.

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 "arrow-down-on-square" component (heroicons-animated/arrow-down-on-square) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/arrow-down-on-square2. 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 { ArrowDownOnSquareIcon } from '@/components/ui/arrow-down-on-square'; export default function Example() { return <ArrowDownOnSquareIcon className='text-neutral-700' size={28} />; }```

Files & dependencies

  • arrow-down-on-square.tsx
dependenciesmotion

Looks similar, elsewhere