An interactive sparkline with path-following indicator, dual-path color reveal, gradient fill, and draw-in animation. Pixel-perfect cursor tracking via binary search on SVG path length.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
Code
"use client";
import { SparkChart } from "@/registry/ruixenui/spark-chart";
const DATA = [
8, 10, 14, 12, 15, 14, 18, 24, 22, 30, 36, 34, 42, 48, 44, 52, 56, 54, 62, 58,
64,
];
export default function SparkChartDemo() {
return (
<div className="flex min-h-[300px] w-full items-center justify-center p-8">
<div className="w-full max-w-sm">
<SparkChart
data={DATA}
height={140}
formatValue={(v) => `$${v.toFixed(0)}k`}
/>
</div>
</div>
);
}
































