Chart

A streaming-friendly sparkline card that shows a labeled metric, a delta badge colored by trend direction, a large value, and an SVG area, line, or bar chart where points appear one at a time as the series streams in. It is driven entirely by props, so the parent controls how many points are visible.

Chart
LIVE · running in a sandboxed iframe
Installed with shadcn add · 1 workaround · theme from registry.json
  • installed base item https://r.assistant-ui.com/shimmer-style.json (registry preview settings)
See how it was built

Installation

pnpm dlx shadcn@latest add @assistant-ui/elements-chart

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

Usage

usage.tsx
import { Chart } from "@/components/assistant-ui/elements/chart";export function Example() {  return (    <Chart      label="Revenue"      value="$12,480"      delta="+8.2%"      points={[3, 5, 4, 7, 6, 9, 12]}      visibleCount={7}    />  );}
  • Showing a live or streaming metric trend (revenue, latency, token counts) inside an assistant or dashboard response
  • Displaying a compact KPI card with a label, a headline value, a delta, and a small trend graphic
  • Rendering a series that arrives incrementally, using visibleCount to reveal points one at a time
  • Choosing between area, line, or bars to show a short numeric series without a full charting library

Examples

Streaming area chart

Reveal points progressively by increasing visibleCount as data arrives.

streaming-area-chart.tsx
import { useEffect, useState } from "react";import { Chart } from "@/components/assistant-ui/elements/chart";const SERIES = [4, 6, 5, 8, 7, 10, 12, 11, 14];export function StreamingRevenue() {  const [count, setCount] = useState(1);  useEffect(() => {    if (count >= SERIES.length) return;    const id = setTimeout(() => setCount((c) => c + 1), 300);    return () => clearTimeout(id);  }, [count]);  return (    <Chart      label="Revenue"      value={`$${SERIES[count - 1]}k`}      delta="+12.0%"      trend="up"      points={SERIES}      visibleCount={count}      variant="area"    />  );}

Latency line chart where up is bad

Set upIsGood to false so a rising value is colored red.

latency-line-chart-where-up-is-bad.tsx
import { Chart } from "@/components/assistant-ui/elements/chart";export function LatencyCard() {  return (    <Chart      label="p95 latency"      value="182 ms"      delta="+24 ms"      points={[120, 130, 128, 150, 165, 182]}      visibleCount={6}      variant="line"      upIsGood={false}    />  );}

Bar chart with explicit flat trend

Bars variant with an explicit trend so a leading minus sign is not misread.

bar-chart-with-explicit-flat-trend.tsx
import { Chart } from "@/components/assistant-ui/elements/chart";export function SignupsCard() {  return (    <Chart      label="Signups"      value="340"      delta="-0"      trend="flat"      points={[30, 42, 38, 35, 40, 37, 34]}      visibleCount={7}      variant="bars"    />  );}

API reference

PropTypeDefaultDescription
labelstring—Muted monospace caption shown at the top left; also used in the SVG aria-label.
valuestring—Large headline value displayed below the header row; also used in the SVG aria-label.
deltastring | undefined—Optional change text shown at the top right. When omitted, no delta is rendered. Direction is inferred from a leading minus sign or a zero-only value unless trend is provided.
pointsreadonly number[]—The full data series. The scale is computed from all points so the y-axis stays stable while visibleCount grows.
visibleCountnumber—How many points from the start of points to draw, clamped between 1 and points.length. Use it to animate a streaming reveal.
variant"area" | "line" | "bars" | undefined"area"Chart rendering style. area draws a filled path under the polyline, line draws only the polyline, bars draws rounded rectangles.
trend"up" | "down" | "flat" | undefined—The direction delta moved in. Overrides inference from the delta string and controls delta color together with upIsGood.
upIsGoodboolean | undefinedtrueWhether a rise is good news (green) or bad news (red). Set to false for metrics like latency. Has no effect when direction is flat or unknown.
classNamestring | undefined—Additional classes merged onto the root card div.

Accessibility

  • The SVG has role="img" and an aria-label combining label and value, so screen readers announce the metric without reading the path data.
  • The delta color conveys good or bad news, so the delta text itself should state the direction (for example a sign or word) rather than relying on color alone.
  • The decorative baseline and polyline carry no separate text; the textual value is the primary information channel.
  • Animations use CSS fade-in classes; respect prefers-reduced-motion in the surrounding app if the stagger is undesirable.
  • Root element is a plain div with data-slot="chart"; spread props can add further ARIA attributes such as aria-describedby.

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" component (assistant-ui/elements-chart) from its shadcn registry.1. Install it with: npx shadcn@latest add @assistant-ui/elements-chart2. 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: label, value, delta, points, visibleCount, variant, trend, upIsGood, className.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Chart } from "@/components/assistant-ui/elements/chart";export function Example() {  return (    <Chart      label="Revenue"      value="$12,480"      delta="+8.2%"      points={[3, 5, 4, 7, 6, 9, 12]}      visibleCount={7}    />  );}```

Files & dependencies

  • components/assistant-ui/elements/chart.tsx
registryDependencieshttps://r.assistant-ui.com/elements-surfaces.jsonhttps://r.assistant-ui.com/elements-range.json

Looks similar, elsewhere