Square Chevron Down

An animated square-chevron-down icon built on motion/react that draws a rounded square outline with a downward chevron inside, which gently bobs down and back when hovered or when its imperative handle is triggered. It is a forwardRef component that exposes startAnimation and stopAnimation methods for programmatic control.

Square Chevron Down
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-chevron-down.json

Usage

usage.tsx
import { SquareChevronDownIcon } from "@/components/ui/square-chevron-down";export default function Example() {  return <SquareChevronDownIcon />;}
  • Showing a collapsible section, dropdown, or 'expand' affordance where a boxed down-chevron is more prominent than a plain chevron.
  • Adding a subtle hover micro-interaction to a button, card header, or menu trigger without custom animation code.
  • Triggering the bob animation programmatically (for example when a list item becomes expandable) through a ref.
  • Decorating navigation or accordion UIs that need a lightweight, themeable icon that follows text color.

Examples

Hover-animated dropdown trigger

Uses the icon as a hover-animated affordance inside a button. The icon's color follows the button's text color through currentColor.

hover-animated-dropdown-trigger.tsx
import { SquareChevronDownIcon } from "@/components/ui/square-chevron-down";export default function DropdownTrigger() {  return (    <button type="button" className="inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm">      Options      <SquareChevronDownIcon size={18} />    </button>  );}

Programmatic control via ref

Calls startAnimation and stopAnimation from a parent through the forwarded ref, for example when an accordion section is about to open.

programmatic-control-via-ref.tsx
import { useRef } from "react";import { SquareChevronDownIcon, type SquareChevronDownIconHandle } from "@/components/ui/square-chevron-down";export default function Accordion() {  const iconRef = useRef<SquareChevronDownIconHandle>(null);  return (    <div>      <button        type="button"        onMouseEnter={() => iconRef.current?.startAnimation()}        onMouseLeave={() => iconRef.current?.stopAnimation()}        className="flex items-center gap-2"      >        Details        <SquareChevronDownIcon ref={iconRef} size={22} />      </button>    </div>  );}

Styled icon with custom className

Applies Tailwind classes to the wrapping div, which receives all extra HTML div attributes.

styled-icon-with-custom-classname.tsx
import { SquareChevronDownIcon } from "@/components/ui/square-chevron-down";export default function StyledIcon() {  return (    <SquareChevronDownIcon      size={32}      className="cursor-pointer text-blue-600 transition-colors hover:text-blue-800"      aria-label="Expand section"      role="img"    />  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels.
classNamestring—Class names applied to the wrapping div (passed through cn).
refReact.Ref<SquareChevronDownIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation() imperative methods.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Called on mouse enter. When the ref handle is in use (controlled mode), the built-in hover animation is disabled and this handler is the only one invoked; otherwise the animation runs first with no extra call.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Called on mouse leave. Same controlled-mode behavior as onMouseEnter.
...HTMLDivElement attributesHTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, role, data-*, etc.) are spread onto the wrapping div.

Accessibility

  • The component renders a decorative SVG with no title or role; add aria-label and role="img" on the wrapper when the icon conveys meaning on its own, or aria-hidden="true" when it sits beside visible text.
  • Because the icon is a plain div wrapper with no built-in button semantics, place it inside a native button or link that carries the accessible name and the expand/collapse state (aria-expanded).
  • The hover animation is a purely visual cue and is not announced to assistive technology; do not rely on it to communicate state.
  • Respect prefers-reduced-motion in the surrounding UI if you trigger startAnimation automatically, since motion/react does not disable the animation on its own.

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

Files & dependencies

  • square-chevron-down.tsx
dependenciesmotion

Looks similar, elsewhere