Line Chart
Token-driven line chart built on Recharts v3 with single and multi-series support, point markers, dashed strokes for non-color differentiation, and full light/dark theming.
Playground
Installation
pnpm add @tessinaui/ui rechartsUsage
import { LineChart } from "@tessinaui/ui";
import type { ChartConfig } from "@tessinaui/ui";
const config: ChartConfig = {
revenue: { label: "Revenue", color: "var(--chart-1)" },
expenses: { label: "Expenses", color: "var(--chart-3)" },
};
const data = [
{ month: "Jan", revenue: 4200, expenses: 2400 },
{ month: "Feb", revenue: 3800, expenses: 2210 },
{ month: "Mar", revenue: 5100, expenses: 2290 },
];
<LineChart
data={data}
config={config}
categoryKey="month"
dashedSeries={["expenses"]}
/>Examples
Default
A smooth, single-series line with a natural curve.
Multiple
Two series in brand tones; expenses dashed so it stays distinct without color.
Curve
The four interpolation modes — monotone, natural, linear, and step.
Sizes
Three aspect ratios — sm (short/wide), md, and lg (tall).
Dots & labels
Point markers on every value, or the value printed above each point.
States
Loading skeleton and empty state.
Non-color differentiation
Colour alone is unreliable for colour-vision-deficient readers. LineChart ships two
encodings you can layer on top of colour:
- Point markers (
showDots, on by default) give each line a distinct dotted trail. - Dashed strokes (
dashedSeries={["expenses"]}) render specific series with a dash pattern.
Combine them with the legend and tooltip so a series can always be identified without colour.
Theming
| Element | Token |
|---|---|
| Series stroke / marker | --chart-1 … --chart-6 (via config[key].color) |
| Grid + axis lines | border |
| Axis tick labels | muted-foreground |
| Tooltip surface | popover / popover-foreground / border |
Accessibility
accessibilityLayeron: keyboard navigation across data points + screen-reader summary.- Animation respects
prefers-reduced-motion: reduce. - Pair colour with markers / dashes / direct labels for colour-independent reading.
Core props
| Prop | Type | Default | Description |
|---|---|---|---|
data | Record<string, string | number | null>[] | — | Row-per-category data. |
config | ChartConfig | — | Series metadata (label, color). |
categoryKey | string | — | Datum key for the x-axis. |
series | string[] | all config keys | Which series to plot. |
curve | "monotone" | "linear" | "step" | "monotone" | Interpolation. |
size | "sm" | "md" | "lg" | "md" | Aspect ratio. |
showGrid / showLegend / showXAxis / showYAxis / showTooltip / showDots | boolean | — | Toggle chart chrome. |
dashedSeries | string[] | [] | Series keys rendered with a dashed stroke. |
dir | "ltr" | "rtl" | "ltr" | Reading direction. |
loading | boolean | false | Render the skeleton. |
error | ReactNode | — | Render an error message instead of the chart. |
emptyState | ReactNode | "No data to display" | Shown when data is empty. |
Label
A foundational form label primitive. Five sizes, five intents, three tones, three weights, required/optional indicators, leading/trailing icons, optional description, and RTL support.
Link
A semantic anchor primitive for navigation, inline prose, and CTAs. Three variants, five sizes, five intents, three tones, configurable underline, external link handling, leading/trailing icons, and RTL support.