Chart
Draws usage over days and values across categories. Two ready charts cover the common cases; ChartContainer wraps any other Recharts chart with the same colors, tooltip, and legend.
Installation
pnpm dlx shadcn@latest add https://sprout.tulipfarm.ai/r/chart.jsonCopies Chart into your app, installs the packages, and adds the styles. Then import it from @/components/ui/chart. Needs Tailwind CSS 4 and a components.json from shadcn init.
Install the following dependencies:
pnpm add clsx tailwind-merge rechartsAdd Sprout base once per app: the
cn()helper and the design tokens.lib/sprout/classes.ts- Design tokens, for your global CSS
Copy and paste the following code into your project.
export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, chartColor, chartIndicatorNames, chartOtherColor, chartPalette, chartShade, type ChartConfig, type ChartContainerProps, type ChartIndicator, type ChartLegendContentProps, type ChartRow, type ChartSeries, type ChartStack, type ChartTooltipContentProps, type ChartTooltipProps, type UsageSeries, type ValueFormatter, } from '@/lib/sprout/chart-kit'; export * from '@/lib/sprout/charts/bars'; export * from '@/lib/sprout/charts/lines'; export * from '@/lib/sprout/charts/parts'; export * from '@/lib/sprout/charts/more';And the files it imports:
lib/sprout/chart-kit.tsxlib/sprout/charts/bars.tsxlib/sprout/charts/lines.tsxlib/sprout/charts/more.tsxlib/sprout/charts/parts.tsx
Add the styles to your global CSS, after
@import "tailwindcss".@layer base { :root, .light { --sprout-red: oklch(58.58% .222 17.58); --sprout-orange: oklch(64.61% .1943 41.12); --sprout-yellow: oklch(65.2% .1388 73.08); --sprout-green: oklch(62.71% .1699 149.21); --sprout-teal: oklch(60.02% .1038 184.7); --sprout-sky: oklch(58.76% .1389 241.97); --sprout-blue: oklch(54.61% .2152 262.88); --sprout-indigo: oklch(51.06% .2301 276.97); --sprout-purple: oklch(55.75% .2525 302.32); --sprout-tan: oklch(61.06% .0869 73.23); } .dark { --sprout-red: oklch(65.79% .1955 13.34); --sprout-orange: oklch(77.98% .1484 67.74); --sprout-yellow: oklch(87.59% .1575 96.07); --sprout-green: oklch(77.5% .1715 145.98); --sprout-teal: oklch(77.28% .0993 201.91); --sprout-sky: oklch(73.46% .111 235.16); --sprout-blue: oklch(65.26% .1738 259.4); --sprout-indigo: oklch(62.3% .1832 282.92); --sprout-purple: oklch(66.45% .1843 308.71); --sprout-tan: oklch(74.86% .0626 77.32); } @media (prefers-color-scheme: dark) { :root:not(.light):not(.dark) { --sprout-red: oklch(65.79% .1955 13.34); --sprout-orange: oklch(77.98% .1484 67.74); --sprout-yellow: oklch(87.59% .1575 96.07); --sprout-green: oklch(77.5% .1715 145.98); --sprout-teal: oklch(77.28% .0993 201.91); --sprout-sky: oklch(73.46% .111 235.16); --sprout-blue: oklch(65.26% .1738 259.4); --sprout-indigo: oklch(62.3% .1832 282.92); --sprout-purple: oklch(66.45% .1843 308.71); --sprout-tan: oklch(74.86% .0626 77.32); } } :root, .light, .dark { --sprout-chart-1: var(--sprout-indigo); --sprout-chart-2: var(--sprout-green); --sprout-chart-3: var(--sprout-orange); --sprout-chart-4: var(--sprout-red); --sprout-chart-5: var(--sprout-sky); --sprout-chart-6: var(--sprout-purple); --sprout-chart-7: var(--sprout-yellow); --sprout-chart-8: var(--sprout-teal); --sprout-chart-9: var(--sprout-blue); --sprout-chart-10: var(--sprout-tan); } } @layer components { .sprout-chart { aspect-ratio: 16 / 9; min-width: 0; font-family: var(--sprout-font); font-size: var(--sprout-text-xs); color: var(--sprout-text); justify-content: center; line-height: 1rem; display: flex; container-type: inline-size; } .sprout-chart .recharts-responsive-container > div > :not(.recharts-wrapper) { width: 100cqi; } .sprout-chart-usage, .sprout-chart-category, .sprout-chart-trend, .sprout-chart-area, .sprout-chart-combo, .sprout-chart-donut, .sprout-chart-funnel, .sprout-chart-waterfall, .sprout-chart-timeline, .sprout-chart-scatter, .sprout-chart-treemap, .sprout-chart-sankey, .sprout-chart-radar, .sprout-chart-sparkline { aspect-ratio: auto; width: 100%; } .sprout-chart-usage { height: 16rem; } .sprout-chart-category, .sprout-chart-trend, .sprout-chart-area, .sprout-chart-combo, .sprout-chart-donut, .sprout-chart-waterfall, .sprout-chart-scatter, .sprout-chart-treemap { height: 18rem; } .sprout-chart-sankey, .sprout-chart-radar { height: 20rem; } .sprout-chart-sparkline { height: 2.5rem; } .sprout-chart-gauge { aspect-ratio: 2 / 1.25; width: 100%; max-width: 20rem; margin-inline: auto; } .sprout-chart .recharts-polar-angle-axis-tick-value { fill: var(--sprout-muted); } .sprout-chart-center-value { fill: var(--sprout-text); font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 600; } .sprout-chart-center-label { fill: var(--sprout-muted); font-size: var(--sprout-text-xs); } .sprout-chart-treemap-label { fill: var(--sprout-surface); pointer-events: none; font-weight: 500; } .sprout-chart-treemap-value { font-variant-numeric: tabular-nums; font-weight: 400; } .sprout-chart-sankey-label { fill: var(--sprout-text); font-weight: 500; } .sprout-chart-sankey-value { fill: var(--sprout-muted); font-variant-numeric: tabular-nums; font-weight: 400; } .sprout-chart-sankey-link:hover { stroke-opacity: .5; } .sprout-chart-heatmap { width: 100%; font-family: var(--sprout-font); font-size: var(--sprout-text-xs); color: var(--sprout-muted); gap: 12px; line-height: 1rem; display: grid; } .sprout-chart-heatmap-scroll { overflow-x: auto; } .sprout-chart-heatmap-table { width: 100%; min-width: calc(var(--sprout-heat-columns) * 1.25rem + 3rem); border-collapse: separate; border-spacing: 3px; table-layout: fixed; } .sprout-chart-heatmap-table th { white-space: nowrap; font-weight: 400; } .sprout-chart-heatmap-table thead th { text-overflow: clip; text-align: center; overflow: hidden; } .sprout-chart-heatmap-table tbody th { text-align: right; width: 3rem; padding-right: 6px; } .sprout-chart-heatmap-table td { border-radius: 3px; height: 1.5rem; position: relative; } .sprout-chart-heatmap-table td[data-tip]:hover { outline: 1.5px solid var(--sprout-text); outline-offset: 1px; } .sprout-chart-heatmap-table td[data-tip]:hover:after { content: attr(data-tip); z-index: 1; border: 1px solid var(--sprout-line); border-radius: var(--sprout-radius-control); background: var(--sprout-surface); color: var(--sprout-text); box-shadow: var(--sprout-shadow-overlay); white-space: nowrap; pointer-events: none; padding: 6px 10px; position: absolute; bottom: calc(100% + 6px); left: 50%; translate: -50%; } .sprout-chart-heatmap-scale { justify-content: flex-end; align-items: center; gap: 3px; display: flex; } .sprout-chart-heatmap-scale > i { border-radius: 2px; width: 12px; height: 12px; } .sprout-chart-heatmap-scale > span:first-child { margin-right: 4px; } .sprout-chart-heatmap-scale > span:last-child { margin-left: 4px; } .sprout-chart-sr-only { clip-path: inset(50%); white-space: nowrap; width: 1px; height: 1px; position: absolute; overflow: hidden; } .sprout-chart .recharts-cartesian-axis-tick-value { fill: var(--sprout-muted); } .sprout-chart .recharts-cartesian-grid line[stroke="oklch(0.8452 0 0)"], .sprout-chart .recharts-polar-grid [stroke="oklch(0.8452 0 0)"], .sprout-chart .recharts-reference-line [stroke="oklch(0.8452 0 0)"] { stroke: var(--sprout-line); } .sprout-chart .recharts-curve.recharts-tooltip-cursor { stroke: var(--sprout-border); } .sprout-chart .recharts-rectangle.recharts-tooltip-cursor { fill: var(--sprout-hover); } .sprout-chart .recharts-radial-bar-background-sector { fill: var(--sprout-secondary); } .sprout-chart .recharts-dot[stroke="oklch(1 0 0)"], .sprout-chart .recharts-sector[stroke="oklch(1 0 0)"] { stroke: #0000; } .sprout-chart .recharts-layer, .sprout-chart .recharts-sector, .sprout-chart .recharts-wrapper, .sprout-chart .recharts-surface { outline: none; } .sprout-chart .recharts-surface { border-radius: var(--sprout-radius-control); overflow: visible; } .sprout-chart .recharts-surface:focus-visible { outline: var(--sprout-focus-width) solid var(--sprout-focus-ring); outline-offset: 0; } .sprout-chart-tooltip { border: 1px solid var(--sprout-line); border-radius: var(--sprout-radius-control); background: var(--sprout-surface); width: max-content; min-width: 8rem; max-width: 20rem; color: var(--sprout-text); box-shadow: var(--sprout-shadow-overlay); font-family: var(--sprout-font); font-size: var(--sprout-text-xs); align-items: start; gap: 6px; padding: 6px 10px; line-height: 1rem; display: grid; } .sprout-chart-tooltip-label { font-weight: 500; } .sprout-chart-tooltip-items { gap: 6px; display: grid; } .sprout-chart-tooltip-item { flex-wrap: wrap; align-items: stretch; gap: 8px; width: 100%; display: flex; } .sprout-chart-tooltip[data-indicator="dot"] .sprout-chart-tooltip-item { align-items: center; } .sprout-chart-tooltip-item > svg { width: 10px; height: 10px; color: var(--sprout-muted); } .sprout-chart-tooltip-indicator { border: 0 solid var(--sprout-chart-indicator); background: var(--sprout-chart-indicator); border-radius: 2px; flex-shrink: 0; } [data-indicator="dot"] .sprout-chart-tooltip-indicator { width: 10px; height: 10px; } [data-indicator="line"] .sprout-chart-tooltip-indicator { width: 4px; } [data-indicator="dashed"] .sprout-chart-tooltip-indicator { background: none; border-style: dashed; border-width: 1.5px; width: 0; } [data-indicator="dashed"] .sprout-chart-tooltip-item:has([data-nested]) .sprout-chart-tooltip-indicator { margin-block: 2px; } .sprout-chart-tooltip-row { flex: 1; justify-content: space-between; align-items: center; gap: 12px; line-height: 1; display: flex; } .sprout-chart-tooltip-row[data-nested] { align-items: flex-end; } .sprout-chart-tooltip-name { gap: 6px; display: grid; } .sprout-chart-tooltip-name > span { color: var(--sprout-muted); } .sprout-chart-tooltip-value { font-variant-numeric: tabular-nums; color: var(--sprout-text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 500; } .sprout-chart-legend { font-family: var(--sprout-font); font-size: var(--sprout-text-xs); color: var(--sprout-text); flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 16px; padding-top: 12px; line-height: 1rem; display: flex; } .sprout-chart-legend[data-align="top"] { padding-top: 0; padding-bottom: 12px; } .sprout-chart-legend-item { align-items: center; gap: 6px; display: flex; } .sprout-chart-legend-item > svg { width: 12px; height: 12px; color: var(--sprout-muted); } .sprout-chart-legend-swatch { border-radius: 2px; flex-shrink: 0; width: 8px; height: 8px; } @media (forced-colors: active) { .sprout-chart-tooltip { border-color: canvastext; } .sprout-chart-tooltip-indicator, .sprout-chart-legend-swatch, .sprout-chart-heatmap-table td, .sprout-chart-heatmap-scale > i { forced-color-adjust: none; } .sprout-chart .recharts-surface:focus-visible { outline-color: highlight; } } }Import it from
@/components/ui/chart. Update the paths if your@/alias points elsewhere.
pnpm add @tulipfarm/sprout@import "tailwindcss";
@import "@tulipfarm/sprout/styles.css";The package keeps the source and ships fixes with each release. Import from @tulipfarm/sprout/chart.
Workspace credits
UsageChart stacks credits by day. The top five groups take chart colors and the rest fold into one muted “N more” series. Hover or focus the chart, then use the arrow keys.
Workspace usage
915.27 credits in the last 30 days · 30.51 a day · UTC
| Model | Calls | Credits | Share |
|---|---|---|---|
| claude-sonnet-4.5 | 1,023 | 337.5 | 37% |
| gpt-5 | 649 | 214.5 | 23% |
| gemini-2.5-pro | 447 | 149 | 16% |
| claude-haiku-4.5 | 329 | 106.5 | 12% |
| gpt-5-mini | 227 | 74 | 8% |
| mistral-large | 81 | 22.8 | 2% |
| llama-4-maverick | 45 | 10.97 | 1% |
Usage
import { UsageChart, type UsageSeries } from "@tulipfarm/sprout/chart";
const series: UsageSeries[] = [
{ key: "s0", label: "claude-sonnet-4.5", color: "var(--sprout-chart-1)" },
{ key: "s1", label: "gpt-5", color: "var(--sprout-chart-2)" },
{ key: "s2", label: "2 more", color: "var(--sprout-muted)" },
];
<UsageChart
days={[
{ date: "2026-10-16", s0: 12.5, s1: 4, s2: 0.6 },
{ date: "2026-10-17", s0: 9, s1: null },
]}
series={series}
/>UsageChartstacks one bar per day, 256px tall. Each day is a row with a UTCdate(YYYY-MM-DD) and a value per series key. A missing ornullvalue leaves that series out of the day’s tooltip. Day labels read like “Oct 17”;localechanges the language.CategoryChartdraws side-by-side bars per category with a legend, 288px tall.categorynames the row key that labels each group.- Both take
title, which names the chart for screen readers, andclassNameto change the height. - Series colors are any CSS color. The palette is
--sprout-chart-1to--sprout-chart-10, with--sprout-mutedfor a folded “N more” series.
Business charts
Fifteen ready charts for dashboards. They share one data shape: rows, the category key that names each row, andseries with a key, label, and color. All taketitle, className, andvalueFormatter for axis ticks and tooltips.
Sparkline
MRR
$91.2k +9.8%
Active users
12,480 +3.1%
Churn
1.9% −0.4 pt
TrendChart
AreaTrendChart · stacked
ComboChart
CategoryChart · horizontal, negative
CategoryChart · percent
DonutChart
DonutChart · pie
GaugeChart
StepFunnelChart
WaterfallChart
HeatmapChart
| 0h | 2h | 4h | 6h | 8h | 10h | 12h | 14h | 16h | 18h | 20h | 22h | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Mon | 0 | 3 | 6 | 10 | 9 | 13 | 16 | 15 | 9 | 8 | 6 | 5 |
| Tue | 1 | 4 | 7 | 7 | 10 | 14 | 17 | 12 | 10 | 9 | 7 | 2 |
| Wed | 2 | 5 | 4 | 8 | 11 | 15 | 14 | 13 | 11 | 10 | 4 | 3 |
| Thu | 3 | 2 | 5 | 9 | 12 | 12 | 15 | 14 | 12 | 7 | 5 | 4 |
| Fri | 0 | 3 | 6 | 10 | 9 | 13 | 16 | 15 | 9 | 8 | 6 | 5 |
| Sat | 6 | 2 | 5 | 1 | 4 | 7 | 3 | 6 | 2 | 5 | 1 | 4 |
| Sun | 7 | 3 | 6 | 2 | 5 | 1 | 4 | 7 | 3 | 6 | 2 | 5 |
TimelineChart
ScatterPlotChart · bubbles
TreemapChart
SankeyChart
RadarScoreChart
import { TrendChart } from "@tulipfarm/sprout/chart";
const usd = (value: number) =>
value.toLocaleString("en-US", { style: "currency", currency: "USD" });
<TrendChart
rows={[
{ month: "Jan", subscriptions: 42000, services: 18000 },
{ month: "Feb", subscriptions: 46000, services: 17000 },
]}
category="month"
series={[
{ key: "subscriptions", label: "Subscriptions", color: "var(--sprout-chart-1)" },
{ key: "services", label: "Services", color: "var(--sprout-chart-2)" },
]}
valueFormatter={usd}
title="Revenue by month"
/>- Over time:
TrendChart(lines;curveis smooth, linear, or step),AreaTrendChart(stackis none, stacked, or percent), andSparkline(a 40px line for stat tiles). - Compare:
CategoryCharttakeshorizontalandstack; negative values hang below a zero line.ComboChartmixes bars and lines; a series withaxis: "right"gets its own scale andrightValueFormatter. - Shares:
DonutChart(orvariant="pie") andTreemapCharttakerows,category, andvalue. The top five parts get chart colors; the rest fold into one muted “N more” part. - Progress and flow:
GaugeChartshowsvalueofmaxas a meter.StepFunnelChartshows each step’s count and share of the first.WaterfallChartadds each step’s change to a running total; steps intotalsstand on zero.SankeyCharttakesnodesandlinksby index. - Patterns:
HeatmapChartis a table of cells in five shades of one color.TimelineChartdraws tasks fromstarttoend, colored byseriesKey; a row with no end is a diamond. It ships from@tulipfarm/sprout/timeline; see Timeline for windows and row actions.ScatterPlotChartplotsxagainsty, withsizefor bubbles.RadarScoreChartcompares scores on many axes. - No chart shares a name with a Recharts export, so you can import both in one file.
Canvas results
Chart results in the canvas
A chat canvas item carries rows, a category key, and series. CategoryChart draws side-by-side bars per category with a legend.
Open tasks by project
Deals won by region
import { CanvasSection } from "@tulipfarm/sprout/canvas";
import { CategoryChart } from "@tulipfarm/sprout/chart";
<CanvasSection title={item.title}>
<CategoryChart rows={content.rows} category={content.category} series={content.series} />
</CanvasSection>Playground
Playground
Daily usage where one day has no notes, three projects with a legend, and the three tooltip indicators.
Daily usage
Categories and legend
Tooltip indicators
dotlinedashedTooltip and legend
Tooltip and legend options
ChartTooltipContent and ChartLegendContent read labels, colors, and icons from the config.
two series · linehideLabelhideIndicatoricons + legendformatterChartTooltipContent:indicatoris"dot"(default),"line", or"dashed". With one series and a line or dashed indicator, the label moves into the row.hideLabel,hideIndicator,labelFormatter,labelClassName,formatter,color,nameKey, andlabelKeychange what it shows.ChartLegendContent:hideIconshows swatches instead of config icons, andnameKeypicks the config entry. On a top legend, the 12px gap moves below it.
Custom charts
Custom chart
ChartContainer around any Recharts chart. Theme colors switch with dark mode; the legend sits on top and shows config icons.
import { CartesianGrid, Line, LineChart, XAxis } from "recharts";
import {
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTooltip,
ChartTooltipContent,
chartColor,
type ChartConfig,
} from "@tulipfarm/sprout/chart";
const config = {
chats: { label: "Chats", theme: { light: "#245cba", dark: "#9cbdff" } },
agentRuns: { label: "Agent runs", color: "var(--sprout-chart-4)" },
} satisfies ChartConfig;
<ChartContainer config={config} style={{ height: 256 }}>
<LineChart data={weeks} accessibilityLayer title="Chats and agent runs by week">
<CartesianGrid vertical={false} />
<XAxis dataKey="week" tickLine={false} axisLine={false} />
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />
<ChartLegend verticalAlign="top" itemSorter={null} content={<ChartLegendContent />} />
<Line dataKey="chats" stroke={chartColor("chats")} dot={false} />
<Line dataKey="agentRuns" stroke={chartColor("agentRuns")} dot={false} />
</LineChart>
</ChartContainer>ChartContainer is 16:9 unless you give it a height. It writes --sprout-chart-color-<key> for each config entry; chartColor(key) returns that variable. Entries with theme switch value in dark mode. ChartStyleis the style tag it renders. ChartTooltip andChartLegend are Recharts’ Tooltip andLegend.
Accessibility
The ready charts turn on Recharts’ accessibility layer. The chart is one tab stop, named by title. Left and Right arrow keys move the tooltip between days or categories, and a 2px focus ring shows. Keep the real numbers in text or a table next to the chart, as the credits page does.
The tooltip moves in 160ms and stays still with reduced motion. Bars draw without animation. In forced colors, the tooltip is outlined and swatches keep their colors.
Theme tokens
Series use --sprout-chart-1 to--sprout-chart-10, with light and dark values. Each points at a named hue: --sprout-indigo, --sprout-green,--sprout-orange, --sprout-red,--sprout-sky, --sprout-purple,--sprout-yellow, --sprout-teal,--sprout-blue, and --sprout-tan. Tailwind gets them as bg-sprout-chart-1 and bg-sprout-greenand so on, for swatches beside a chart. Ticks use --sprout-muted, grid lines--sprout-line, the hover band --sprout-hover, and the tooltip --sprout-surface with--sprout-line.