play

PlayIcon is an animated play-button glyph from the hugeicons-animated registry. On hover it compresses, releases forward with a small overshoot, and settles back into its resting shape, with the animation driven by motion/react.

play
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/play

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

Usage

usage.tsx
import { PlayIcon } from '@/components/icons/play';export default function Example() {  return <PlayIcon className='text-foreground' />;}
  • Play, start, or media-playback controls in video, audio, or podcast UIs where a subtle hover cue helps.
  • Call-to-action buttons or cards that should feel responsive without adding loud effects.
  • Imperative triggering of the play animation from parent state, for example when a video starts playing.
  • Playful marketing or onboarding sections that need a lightweight animated icon.

Examples

Basic hover play icon

Renders the icon with default size (28px). The animation runs once on mouse enter.

basic-hover-play-icon.tsx
import { PlayIcon } from '@/components/icons/play';export default function BasicExample() {  return (    <div className='flex items-center justify-center p-6'>      <PlayIcon className='text-foreground' />    </div>  );}

Controlled via ref

Uses the PlayIconHandle ref to start the animation from parent logic. Mouse hover animation is skipped while the ref is attached.

controlled-via-ref.tsx
import { useRef } from 'react';import { PlayIcon, type PlayIconHandle } from '@/components/icons/play';export default function ControlledExample() {  const iconRef = useRef<PlayIconHandle>(null);  return (    <div className='flex items-center gap-3'>      <PlayIcon ref={iconRef} size={32} className='text-emerald-500' />      <button        type='button'        className='rounded-md border px-3 py-1 text-sm'        onClick={() => iconRef.current?.startAnimation()}      >        Play      </button>    </div>  );}

Custom size with mouse callbacks

Sets a custom size and forwards onMouseEnter and onMouseLeave to the wrapper div, which are called before the internal animation handling.

custom-size-with-mouse-callbacks.tsx
import { PlayIcon } from '@/components/icons/play';export default function CallbackExample() {  return (    <PlayIcon      size={20}      className='cursor-pointer text-blue-600'      role='img'      aria-label='Play video'      onMouseEnter={() => console.log('hover start')}      onMouseLeave={() => console.log('hover end')}    />  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. The viewBox stays 24x24.
classNamestring—Class names applied to the wrapping div (passed through cn). Use text-* utilities to change the stroke color, since the stroke uses currentColor.
refReact.Ref<PlayIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation(). Attaching the ref switches the component to controlled mode, so hover no longer triggers the animation automatically.
onMouseEnterReact.MouseEventHandler<HTMLDivElement>—Optional callback invoked on mouse enter before the built-in animation starts.
onMouseLeaveReact.MouseEventHandler<HTMLDivElement>—Optional callback invoked on mouse leave before the built-in stop logic runs.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, role, aria-*, style, data-*, etc.) are spread onto the wrapping div.
PlayIconHandle.startAnimation() => void—Imperatively plays the animation once. Does nothing when prefers-reduced-motion is set or an animation is already running.
PlayIconHandle.stopAnimation() => void—Resets the icon to its resting state only when the internal loops option is enabled. This component sets loops to false, so calling it is a no-op.

Accessibility

  • The wrapper div and the SVG have no built-in role or label. The icon is decorative by default, so add aria-hidden='true' when a visible text label is present nearby.
  • When the icon is the only content of a control, give the wrapper role='img' and an aria-label such as 'Play video', or place the icon inside a labeled button.
  • The hook checks useReducedMotion from motion/react and skips starting the animation when the user prefers reduced motion, so the hover effect respects that preference.
  • The animation is short (about 0.52s) and runs once per hover, so it does not loop or flash repeatedly.
  • Because the icon uses currentColor, its contrast follows the text color. Make sure the chosen color meets WCAG contrast against the background.
  • Avoid nesting this component inside a native button element, since it renders a div. Wrap it in a non-interactive container or use a div-based clickable area with proper keyboard handling.

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

Files & dependencies

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

Looks similar, elsewhere