History

HistoryIcon is an animated SVG icon of a clock with a counter-clockwise arrow, built on motion/react. On hover, the arrow swings back and the hour and minute hands rotate, and a parent can drive the same animation through a ref.

History
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/history.json

Usage

usage.tsx
import { HistoryIcon } from "@/components/ui/history";export function Example() {  return <HistoryIcon />;}
  • Showing a history, undo-history, recent-activity, or timeline action in toolbars, menus, or sidebars
  • Adding a playful hover micro-interaction to a navigation item or icon button
  • Triggering the clock-rewind animation from application state (for example, while a history panel loads) through the imperative ref handle
  • Replacing a static history or clock icon where a lightweight animated SVG is acceptable

Examples

Basic hover animation

Renders the icon at its default size. Hovering the wrapper plays the rewind animation automatically.

basic-hover-animation.tsx
import { HistoryIcon } from "@/components/ui/history";export default function BasicHistory() {  return (    <div className="inline-flex cursor-pointer text-foreground">      <HistoryIcon />    </div>  );}

Controlled animation via ref

Passing a ref switches the icon into controlled mode. Hover no longer triggers the animation; the parent calls startAnimation and stopAnimation instead.

controlled-animation-via-ref.tsx
import { useRef } from "react";import { Button } from "@/components/ui/button";import { HistoryIcon, type HistoryIconHandle } from "@/components/ui/history";export default function ControlledHistory() {  const iconRef = useRef<HistoryIconHandle>(null);  return (    <Button      variant="outline"      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <HistoryIcon ref={iconRef} size={16} />      History    </Button>  );}

Menu item with custom size and class

Uses size and className to fit a sidebar menu row. Standard div props such as aria-label are forwarded to the wrapper.

menu-item-with-custom-size-and-class.tsx
import { HistoryIcon } from "@/components/ui/history";export default function SidebarHistoryItem() {  return (    <button className="flex items-center gap-2 rounded-md px-3 py-2 hover:bg-accent">      <HistoryIcon size={20} className="text-muted-foreground" aria-label="Open history" />      <span>Recent activity</span>    </button>  );}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels. The viewBox stays 0 0 24 24.
classNamestring—Class names applied to the wrapping div via cn(). Use it for color, margin, and layout (the stroke uses currentColor).
refReact.Ref<HistoryIconHandle>—Forwarded ref exposing startAnimation() and stopAnimation(). Attaching it switches the component to controlled mode, where hover events call the optional onMouseEnter and onMouseLeave props instead of starting the animation automatically.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Called on mouse enter. In uncontrolled mode the built-in animation runs first. In controlled mode (ref attached) only this handler runs, so the parent must call startAnimation itself.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Called on mouse leave. In uncontrolled mode the icon returns to its resting pose. In controlled mode only this handler runs.
...HTMLAttributes<HTMLDivElement>HTMLAttributes<HTMLDivElement>—All other standard div attributes (id, style, aria-*, role, onClick, and so on) are spread onto the wrapping div.

Accessibility

  • The SVG has no title or role, so the icon is decorative by default. If it conveys meaning on its own, add aria-label or role="img" on the wrapper, or place visible text next to it.
  • When the icon sits inside an interactive element such as a button, give the button an accessible name. The icon itself should stay aria-hidden when visible text already describes the action.
  • Motion is limited to a short hover rotation. For users who prefer reduced motion, consider skipping the controlled startAnimation call based on prefers-reduced-motion.
  • The icon inherits currentColor, so it keeps the contrast of its surrounding text. Make sure the parent color meets WCAG contrast requirements.

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

Files & dependencies

  • history.tsx
dependenciesmotion

Looks similar, elsewhere