forward

An animated forward icon for React built on motion/react. Hovering over it, or calling its imperative handle, plays a short wiggle that nudges the icon sideways and tilts it slightly.

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

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

Usage

usage.tsx
import { ForwardIcon } from "@/components/ui/forward";export function Example() {  return <ForwardIcon />;}
  • Next, skip-forward, or fast-forward controls in media players, carousels, and step-through wizards where a hover cue adds feedback.
  • Call-to-action buttons or navigation links that should signal forward movement with a subtle animated icon.
  • Interfaces that need to trigger the forward animation programmatically (for example on step completion) through a ref.
  • Marketing or landing pages that want a lightweight, playful micro-interaction on an icon.

Examples

Basic hover animation

Hovering the icon plays the forward animation automatically. No ref is needed.

basic-hover-animation.tsx
import { ForwardIcon } from "@/components/ui/forward";export function HoverForward() {  return (    <div className="inline-flex cursor-pointer items-center text-neutral-700">      <ForwardIcon size={24} />    </div>  );}

Programmatic control via ref

Attaching a ref switches the component to controlled mode. Hover no longer animates it on its own; call startAnimation and stopAnimation from the parent instead.

programmatic-control-via-ref.tsx
import { useRef } from "react";import { ForwardIcon, type ForwardIconHandle } from "@/components/ui/forward";export function NextStepButton() {  const iconRef = useRef<ForwardIconHandle>(null);  return (    <button      type="button"      className="inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      Next      <ForwardIcon ref={iconRef} size={16} />    </button>  );}

Custom size and color

size sets the SVG width and height. Color comes from text color via currentColor, and className is applied to the wrapper div.

custom-size-and-color.tsx
import { ForwardIcon } from "@/components/ui/forward";export function BlueForward() {  return <ForwardIcon size={32} className="text-blue-600 dark:text-blue-400" aria-label="Forward" role="img" />;}

Triggering the animation when a step completes

Calling startAnimation from an effect provides feedback without any user hover.

triggering-the-animation-when-a-step-completes.tsx
import { useEffect, useRef } from "react";import { ForwardIcon, type ForwardIconHandle } from "@/components/ui/forward";export function StepHint({ completed }: { completed: boolean }) {  const iconRef = useRef<ForwardIconHandle>(null);  useEffect(() => {    if (completed) iconRef.current?.startAnimation();  }, [completed]);  return <ForwardIcon ref={iconRef} size={20} />;}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. Applied to the svg element's width and height attributes.
classNamestring—Class names applied to the outer wrapper div (not the svg). Merged with cn().
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler. When a ref is attached (controlled mode), it is called instead of the built-in animation starting.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler. When a ref is attached (controlled mode), it is called instead of the built-in animation resetting.
refReact.Ref<ForwardIconHandle>—Exposes ForwardIconHandle with startAnimation() and stopAnimation() methods. Attaching it switches the component to controlled mode.
...propsHTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, data-*, etc.) are spread onto the wrapper div.

Accessibility

  • The icon is decorative by default: the svg has no title or aria-label. Add aria-label and role="img" on the wrapper, or pair it with visible text, when it conveys meaning on its own.
  • Hover-only animation gives no feedback to keyboard or touch users. Pair it with a focusable parent (button or link) and avoid relying on it as the only state signal.
  • Respect reduced motion preferences by avoiding programmatic startAnimation calls when the user has requested reduced motion, using prefers-reduced-motion in the parent.
  • The wrapper is a plain div with no implicit role, so place it inside an interactive element (button or a) that provides the accessible name and keyboard operation.

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 "forward" component (heroicons-animated/forward) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/forward2. 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 { ForwardIcon } from "@/components/ui/forward";export function Example() {  return <ForwardIcon />;}```

Files & dependencies

  • forward.tsx
dependenciesmotion

Looks similar, elsewhere