chevron-up
An animated chevron-up (upward caret) icon for React that nudges upward with a short bounce on hover or when triggered through a ref. It is built on motion/react and renders an SVG stroke icon from Heroicons.
shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @heroicons-animated in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { ChevronUpIcon } from '@/components/ui/chevron-up';export function Example() { return <ChevronUpIcon size={24} className='text-zinc-700' />;}- Indicating an expanded or collapsible section (accordion, disclosure, or dropdown header) where the chevron points up to show 'collapse' or 'scroll up'.
- Adding a subtle hover affordance to up-pointing buttons such as 'back to top' or 'show less' links.
- Triggering the bounce programmatically (for example on a data update or step change) via the forwarded ref's startAnimation method.
- Replacing a static chevron-up icon in a React UI that already uses motion/react and Tailwind-style className utilities.
Examples
Basic hover icon
Renders the icon with default size (28) and plays the bounce when the pointer enters the wrapper.
import { ChevronUpIcon } from '@/components/ui/chevron-up';export default function BasicExample() { return <ChevronUpIcon />;}Controlled via ref
Uses the forwarded ref to start and stop the animation from parent handlers, for example on a wrapper element.
import { useRef } from 'react';import { ChevronUpIcon, type ChevronUpIconHandle } from '@/components/ui/chevron-up';export default function ControlledExample() { const iconRef = useRef<ChevronUpIconHandle>(null); return ( <div onMouseEnter={() => iconRef.current?.startAnimation()} onMouseLeave={() => iconRef.current?.stopAnimation()} className='inline-flex cursor-pointer' > <ChevronUpIcon ref={iconRef} size={24} /> </div> );}Collapse button
Places the icon inside a text button as a 'show less' affordance, sized to match the label.
import { ChevronUpIcon } from '@/components/ui/chevron-up';export default function CollapseButton() { return ( <button type='button' className='flex items-center gap-1 text-sm font-medium text-zinc-800'> Show less <ChevronUpIcon size={16} /> </button> );}API reference
Accessibility
- The icon is a decorative SVG with no role, title, or aria-label. If it conveys meaning (for example, a 'collapse' control), place an accessible name on the parent button or link, or add aria-label/aria-hidden on the wrapper as appropriate.
- Animation is brief (0.5s) and small (about 2px). Respect prefers-reduced-motion by avoiding the imperative startAnimation call or by wrapping usage in a motion-reduce check if strict reduced motion is required.
- Because the icon is hover-driven, do not rely on hover alone to communicate state; pair it with text or aria-expanded on the disclosure control.
- Make sure the parent interactive element is focusable and has a visible focus style, since the icon itself is not focusable.
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.
Use the "chevron-up" component (heroicons-animated/chevron-up) from its shadcn registry.1. Install it with: npx shadcn@latest add @heroicons-animated/chevron-up2. 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 { ChevronUpIcon } from '@/components/ui/chevron-up';export function Example() { return <ChevronUpIcon size={24} className='text-zinc-700' />;}```Files & dependencies
- chevron-up.tsx