A tiny trend chart for KPI cards and table cells, plus a colour palette and themes for Recharts and ECharts.
import { Sparkline, chartColor, rechartsTheme, echartsTheme, readChartTheme } from "@kivu-ui/react"On this page
import { Sparkline, chartColor, rechartsTheme, echartsTheme, readChartTheme } from "@kivu-ui/react";import { Sparkline } from "@kivu-ui/react";
const visits = [120, 132, 128, 150, 162, 158, 171, 190, 184, 205, 214, 232];
export default function Demo() {
return (
<div className="grid w-full max-w-md gap-6">
<Sparkline data={visits} label="Visits, last 12 weeks: up from 120 to 232" />
<Sparkline data={visits} area={false} color="var(--kivu-chart-2)" height={32} />
<Sparkline variant="bar" data={[4, 7, 5, 9, 6, 11, 8, 12]} color="var(--kivu-chart-3)" />
</div>
);
}Eight series colours, ordered so neighbours stay distinct for colour-blind readers, in light and dark mode. Use chartColor(i) in Recharts; for ECharts, register echartsTheme(readChartTheme()). Label series with a legend, not by colouring text.
--kivu-chart-1--kivu-chart-2--kivu-chart-3--kivu-chart-4--kivu-chart-5--kivu-chart-6--kivu-chart-7--kivu-chart-8import { chartSeries } from "@kivu-ui/react";
export default function Demo() {
return (
<div className="grid w-full max-w-md gap-2">
{chartSeries.map((color, i) => (
<div key={color} className="flex items-center gap-3 text-sm text-fg-muted">
<span className="h-3 rounded-full" style={{ background: color, width: `${92 - i * 9}%` }} />
<code className="shrink-0 font-mono text-xs">--kivu-chart-{i + 1}</code>
</div>
))}
</div>
);
}Extends <div> attributes.
| Prop | Type | Default | Description |
|---|---|---|---|
data | number[] | - | Required. Values, oldest first. |
variant | "line" | "bar" | "line" | Line for trends, bars for counts per period. |
height | number | 40 | Height in px. Width fills the container. |
color | string | "var(--kivu-chart-1)" | Any CSS colour. |
area | boolean | true | Soft fill under the line. |
highlightLast | boolean | true | Dot on the latest value, or highlight the latest bar. |
domain | [min, max] | - | Fix the vertical scale. |
label | string | - | Accessible description. |
| Prop | Type | Default | Description |
|---|---|---|---|
chartColor(i) | string | - | var(--kivu-chart-N) for series i (0-based). Works in SVG charts and follows dark mode. |
rechartsTheme | object | - | Props to spread: grid, xAxis, yAxis, tooltip, legend, line, area, bar. |
readChartTheme(el?) | ResolvedChartTheme | - | Resolves the tokens to hex values for canvas charts. Re-run on theme change. |
echartsTheme(theme) | object | - | ECharts theme from a mode or a resolved theme. |
chartColors | { light, dark } | - | The palette as hex values. |
Every component also accepts className and forwards its ref. Root CSS class: .kivu-spark