refresh

An animated refresh icon that rewinds slightly and then spins one full revolution when hovered or triggered through a ref. It renders an inline SVG with a stroked open-circle arrow and uses motion for the rotation.

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

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

Usage

usage.tsx
import { RefreshIcon } from '@/components/icons/refresh';export function Demo() {  return <RefreshIcon className={'text-primary'} />;}
  • Use on buttons or toolbar actions that reload, sync, retry, or refresh data.
  • Use in navigation or dashboards where a subtle hover-triggered spin signals a refresh action.
  • Use when you need to start the spin programmatically (for example after a fetch) via the exposed ref handle.
  • Avoid it for static UI where motion is not desired; the animation is skipped when the user prefers reduced motion.

Examples

Basic hover animation

Hovering the icon plays one spin. The icon inherits its color from the text color via currentColor.

basic-hover-animation.tsx
import { RefreshIcon } from '@/components/icons/refresh';export function HoverRefresh() {  return (    <div className={'inline-flex items-center gap-2 text-foreground'}>      <RefreshIcon size={24} />      <span>Sync</span>    </div>  );}

Controlled spin from a button

Once a ref is attached, hover no longer triggers the animation. Call startAnimation from your own handlers instead.

controlled-spin-from-a-button.tsx
import { useRef } from 'react';import { Button } from '@/components/ui/button';import { RefreshIcon, type RefreshIconHandle } from '@/components/icons/refresh';export function ReloadButton() {  const iconRef = useRef<RefreshIconHandle>(null);  return (    <Button variant="outline" onClick={() => iconRef.current?.startAnimation()}>      <RefreshIcon ref={iconRef} size={16} />      Reload    </Button>  );}

Spin while data is loading

Starts the spin when a fetch begins. Repeated calls while a spin is running are ignored.

spin-while-data-is-loading.tsx
import { useEffect, useRef } from 'react';import { RefreshIcon, type RefreshIconHandle } from '@/components/icons/refresh';export function SyncStatus({ isLoading }: { isLoading: boolean }) {  const iconRef = useRef<RefreshIconHandle>(null);  useEffect(() => {    if (isLoading) iconRef.current?.startAnimation();  }, [isLoading]);  return <RefreshIcon ref={iconRef} size={20} className={isLoading ? 'text-primary' : 'text-muted-foreground'} />;}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. The viewBox stays 0 0 24 24.
classNamestring—Class applied to the outer wrapper div (passed through cn).
onMouseEnterMouseEventHandler<HTMLDivElement>—Called on mouse enter before the built-in animation starts.
onMouseLeaveMouseEventHandler<HTMLDivElement>—Called on mouse leave before the built-in stop logic runs. Stopping only has an effect when the internal loops option is enabled, which this icon does not use.
refForwardedRef<RefreshIconHandle>—Exposes RefreshIconHandle with startAnimation() and stopAnimation(). Attaching a ref switches the icon to controlled mode, disabling hover-triggered animation. stopAnimation is a no-op for this non-looping icon.
...propsHTMLAttributes<HTMLDivElement>—Any other div attributes (id, style, aria-*, data-*, etc.) are spread onto the outer wrapper div.

Accessibility

  • The icon is decorative SVG with no title or role; if it conveys meaning alone, wrap it in an element with aria-label or provide visible text nearby.
  • When the icon is inside a button, the button needs an accessible name (visible text or aria-label), since the icon itself contributes none.
  • The animation is skipped automatically when the user has enabled reduced motion (prefers-reduced-motion), so no extra handling is needed.
  • Hover-only triggers are not reachable by keyboard; when the spin signals an action, pair it with a focusable control that performs the action.

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 "refresh" component (hugeicons-animated/refresh) from its shadcn registry.1. Install it with: npx shadcn@latest add @hugeicons-animated/refresh2. 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 { RefreshIcon } from '@/components/icons/refresh';export function Demo() {  return <RefreshIcon className={'text-primary'} />;}```

Files & dependencies

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

Looks similar, elsewhere