Square Arrow Left

An animated square-with-left-arrow icon built on motion/react that plays a small leftward nudge of the arrow inside a rounded square when hovered or when its imperative handle is triggered. It renders a 24x24 stroked SVG at a configurable size and is styled through currentColor.

Square Arrow Left
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 https://lucide-animated.com/r/square-arrow-left.json

Usage

usage.tsx
import { SquareArrowLeftIcon } from "@/components/ui/square-arrow-left";export default function Example() {  return <SquareArrowLeftIcon />;}
  • Back, previous, or return navigation buttons in a toolbar or header where a square icon style is desired
  • Animated UI affordances that should respond to hover on desktop while staying a static icon otherwise
  • Interactive controls that need to trigger the arrow animation programmatically via a ref, for example when a form step changes
  • Icon sets that need a consistent stroke-based style with currentColor theming in light and dark modes

Examples

Hover-animated back button

Wraps the icon in a button so the hover animation plays when the user points at the control.

hover-animated-back-button.tsx
import { SquareArrowLeftIcon } from "@/components/ui/square-arrow-left";export default function BackButton() {  return (    <button type="button" className="inline-flex items-center gap-2 text-sm font-medium">      <SquareArrowLeftIcon size={20} className="text-foreground" />      Back    </button>  );}

Programmatic control via ref

Uses the exported handle type to start and stop the animation from parent logic, such as when a wizard step changes.

programmatic-control-via-ref.tsx
import { useRef } from "react";import { SquareArrowLeftIcon, type SquareArrowLeftIconHandle } from "@/components/ui/square-arrow-left";export default function Wizard() {  const iconRef = useRef<SquareArrowLeftIconHandle>(null);  return (    <div      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <SquareArrowLeftIcon ref={iconRef} size={32} />    </div>  );}

Custom size and color in a navigation bar

Sets a larger size and uses a Tailwind text color class so the stroke inherits the color.

custom-size-and-color-in-a-navigation-bar.tsx
import { SquareArrowLeftIcon } from "@/components/ui/square-arrow-left";export default function NavBar() {  return (    <nav className="flex items-center p-4">      <SquareArrowLeftIcon size={36} className="text-blue-600 cursor-pointer" />    </nav>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the rendered SVG in pixels. Applied to both the width and height attributes.
classNamestring—Class name applied to the outer wrapper div. Use text color utilities to set the stroke color via currentColor.
refRef<SquareArrowLeftIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation(). Using it switches the component into controlled mode, so hover events are forwarded to the onMouseEnter and onMouseLeave props instead of auto-animating.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler. Called in controlled mode after the component has received a ref; otherwise the animation runs automatically and this handler is not invoked by the component.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler. Called in controlled mode after the component has received a ref; otherwise the animation resets automatically and this handler is not invoked by the component.

Accessibility

  • The icon is decorative SVG with no role, title, or aria-label; when it conveys meaning, wrap it in a button or link with an accessible name such as aria-label="Back".
  • Hover-only animation does not convey information, so the state change should not be the only signal to the user.
  • Respect reduced motion preferences by avoiding excessive use of the animation in surrounding UI, since the component itself does not check prefers-reduced-motion.
  • Ensure the parent interactive element has visible focus styling, because the icon wrapper div is not focusable by default.
  • Color contrast depends on the currentColor applied via className; choose a text color that meets WCAG contrast against the background.

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 "Square Arrow Left" component (lucide-animated/square-arrow-left) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/square-arrow-left.json2. 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.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { SquareArrowLeftIcon } from "@/components/ui/square-arrow-left";export default function Example() {  return <SquareArrowLeftIcon />;}```

Files & dependencies

  • square-arrow-left.tsx
dependenciesmotion

Looks similar, elsewhere