Chart Spline

An animated chart-spline icon for React that draws a rising curve across a line chart axis using Motion. It animates on hover by default, or can be triggered programmatically through a ref handle.

Chart Spline
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/chart-spline.json

Usage

usage.tsx
import { ChartSplineIcon } from "@/components/ui/chart-spline";export function Example() {  return <ChartSplineIcon size={28} />;}
  • Showing analytics, statistics, or performance trend UI such as dashboards and reports
  • Decorating a 'growth' or 'metrics' feature card or navigation entry with a subtle hover animation
  • Triggering a chart-drawing animation programmatically when data loads, via the imperative ref handle

Examples

Hover-activated icon in a stat card

Default hover behavior: the spline draws when the pointer enters the wrapper and resets when it leaves.

hover-activated-icon-in-a-stat-card.tsx
import { ChartSplineIcon } from "@/components/ui/chart-spline";export function RevenueCard() {  return (    <div className="flex items-center gap-3 rounded-lg border p-4">      <ChartSplineIcon className="text-emerald-500" size={32} />      <div>        <p className="text-sm text-muted-foreground">Revenue</p>        <p className="text-xl font-semibold">$12,400</p>      </div>    </div>  );}

Programmatic control via ref

Once a ref is attached, hover events are forwarded to the optional onMouseEnter/onMouseLeave props and the animation is driven by startAnimation/stopAnimation.

programmatic-control-via-ref.tsx
import { useRef } from "react";import { Button } from "@/components/ui/button";import {  ChartSplineIcon,  type ChartSplineIconHandle,} from "@/components/ui/chart-spline";export function LoadChartButton() {  const iconRef = useRef<ChartSplineIconHandle>(null);  return (    <Button      onMouseEnter={() => iconRef.current?.startAnimation()}      onMouseLeave={() => iconRef.current?.stopAnimation()}    >      <ChartSplineIcon ref={iconRef} size={20} className="mr-2" />      View trends    </Button>  );}

Animate when data becomes available

Use the handle inside an effect to play the draw animation once content has loaded.

animate-when-data-becomes-available.tsx
import { useEffect, useRef } from "react";import {  ChartSplineIcon,  type ChartSplineIconHandle,} from "@/components/ui/chart-spline";export function MetricsHeader({ loaded }: { loaded: boolean }) {  const iconRef = useRef<ChartSplineIconHandle>(null);  useEffect(() => {    if (loaded) iconRef.current?.startAnimation();  }, [loaded]);  return <ChartSplineIcon ref={iconRef} size={24} />;}

API reference

PropTypeDefaultDescription
sizenumber28Width and height of the SVG in pixels.
classNamestring—Class names applied to the wrapping div (passed through cn). Use text-* utilities to change the stroke color.
onMouseEnter(e: React.MouseEvent<HTMLDivElement>) => void—Mouse enter handler. Called instead of the built-in animation once a ref handle has been attached.
onMouseLeave(e: React.MouseEvent<HTMLDivElement>) => void—Mouse leave handler. Called instead of the built-in animation once a ref handle has been attached.
refReact.Ref<ChartSplineIconHandle>—Exposes startAnimation() (plays the draw animation) and stopAnimation() (resets to the normal state). Accepts all other HTMLDivElement attributes via spread.

Accessibility

  • The component renders no role or aria-label; when it conveys meaning, add aria-label or a visible text label on the parent element.
  • If the icon is purely decorative (next to visible text), add aria-hidden="true" via props to hide it from assistive technology.
  • The animation is a one-shot draw and fade; it does not loop, but users with reduced-motion preferences may want to disable hover triggering by not passing the ref or by gating calls on matchMedia('(prefers-reduced-motion: reduce)').
  • Hover-only triggering is not available to keyboard users; pair the icon with focusable controls and call startAnimation on focus when the animation conveys important state.

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 "Chart Spline" component (lucide-animated/chart-spline) from its shadcn registry.1. Install it with: npx shadcn@latest add https://lucide-animated.com/r/chart-spline.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, onMouseEnter, onMouseLeave, ref.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { ChartSplineIcon } from "@/components/ui/chart-spline";export function Example() {  return <ChartSplineIcon size={28} />;}```

Files & dependencies

  • chart-spline.tsx
dependenciesmotion

Looks similar, elsewhere