Line Chart

Change over time for up to five series: smooth, linear, step or bump curves; solid, dashed or dotted strokes; gradient and glow.

Category
Data & feedback
Access
Free with an account
Source
186 lines · one file
States
7 drawn

The decision inside it

Strokes tell series apart, not only colour

With a one-hue palette, dashed and dotted lines are what separate a target from the real number, and they survive a greyscale print.

When to use it

Use Line Chart for change over time with one to five series on one axis. Give a target or forecast series stroke: "dashed". Pick curve smooth, linear, step or bump, and effect gradient or glow if you want it.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Line Chart for this.
Install it: npx shadcn@latest add @liro/line-chart
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/line-chart.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/signed-chart.tsx
import { ChartCard } from "@/components/ui/chart";
import { LineChart } from "@/components/ui/line-chart";

const data = [
  { week: "Oct 5", signed: 612, target: 600 },
  { week: "Oct 12", signed: 655, target: 600 },
  { week: "Oct 19", signed: 684, target: 600 },
];

export function SignedChart({ loading }: { loading: boolean }) {
  return (
    <ChartCard title="Documents signed" subtitle="Per week">
      <LineChart
        data={data}
        xKey="week"
        loading={loading}
        description="Documents signed per week against a target of 600"
        series={[
          { key: "signed", label: "Signed" },
          { key: "target", label: "Target", stroke: "dashed" },
        ]}
      />
    </ChartCard>
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
dataT[] Yes–
xKeykeyof T & string Yes–
seriesLineSeries[] Yes–
curveLineCurve NoDefault "smooth".
effectLineEffect NoDefault "none".
dotsboolean NoDraw every point, not only on hover.
endDotboolean NoMark the last point of each line. Default true.
format(v: number) => string NoValue formatter for the axis, tooltip and table.
xFormat(v: string) => string NoLabel formatter for the x-axis and tooltip.
heightnumber No–
descriptionstring YesAccessible summary, read before the data table.
loadingboolean No–
errorReact.ReactNode No–
onRetry() => void No–
classNamestring No–

Dependencies

npm packages

clsxrechartstailwind-merge

Liro foundations, installed alongside it

liro-themechart

States

All of them are drawn by the component. None is left for you to design.

  • Smooth
  • Step
  • Gradient
  • Glow
  • Loading
  • Empty
  • Error

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances