Skip to content
Components

Chart

Gradient-first charts on TanStack Charts: themed host, presets that return real definitions, and the full grammar.

Examples

Line

Smooth lines with dots for comparing a few series over time; the crosshair groups every series at the hovered month.

Bar

Grouped vertical bars compare categories side by side; negative values hang below the zero line.

Horizontal stacked bar

Horizontal bars fit long category names. Switch between absolute stacks and a percent share of each row.

Scatter

Correlation between two measures, with bubble size for a third and color for the group.

Donut

Share of a total, with the total itself in ChartCenter. A hatched slice marks the catch-all bucket.

Radial bar

Progress rings toward a shared goal; the hatched track shows what remains.

Sparkline

Axis-free trend lines sized for KPI cards; they skip focus and tooltips so the card stays one tab stop.

Status page

Axis-free status charts. xScale and yScale take axis: false; a series color accepts any CSS color such as var(--success), and on bars a function of the row colors each bar by its own day. A numeric radius rounds every bar corner, and formatValue(value, row) reads the whole row for the tooltip.

Actual vs. forecast

Hatching separates projected from measured values: a dashed hatched forecast area, and a hatched planned series in bars. Hatch patterns come from the palette, so a series with a CSS color paints solid.

Interactive legend

Legend toggles hide series. Colors resolve from the full series list, so the remaining series keep their hue.

Loading and empty

Compose Skeleton while data loads and Empty when it arrives with no rows; presets accept an empty array without throwing.

Composition

Card chart

  • <Chart>
    • <ChartPlot>
      • <ChartTooltipBody />
      </ChartPlot>
    • <ChartLegend>
      • <ChartLegendItem />
      </ChartLegend>
    </Chart>

Donut with total

  • <Chart>
    • <ChartPlot>
      • <ChartCenter />
      </ChartPlot>
    • <ChartLegend>
      • <ChartLegendItem />
      </ChartLegend>
    </Chart>

Installation

The Control UI source installs this component from src/registry/sources/control-ui/ui/chart.tsx.

Registry command
See registry manifest

Dependencies

Cartesian presetssrc/registry/sources/control-ui/ui/chart-cartesian.tsSupport
Palettesrc/registry/sources/control-ui/ui/chart-colors.tsSupport
Curvessrc/registry/sources/control-ui/ui/chart-curves.tsSupport
Building blockssrc/registry/sources/control-ui/ui/chart-marks.tsSupport
Polar presetssrc/registry/sources/control-ui/ui/chart-polar.tsSupport
Series modelsrc/registry/sources/control-ui/ui/chart-series.tsSupport
Motionsrc/registry/lib/motion.tsUtil

Raw code

Primary installed source

src/registry/sources/control-ui/ui/chart.tsx

Knobs

Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.

--cui-chart-* · 19 knobsHow the cascade resolves
--cui-chart-foreground<color>var(--muted-foreground)
--cui-chart-background<color>var(--card)
--cui-chart-line-size<length-percentage>2px
--cui-chart-area-opacity<number>1
--cui-chart-hatch-opacity<number>0.6
--cui-chart-hatch-tint-opacity<number>0.12
--cui-chart-tooltip-background<color>var(--popover)
--cui-chart-tooltip-foreground<color>var(--popover-foreground)
--cui-chart-tooltip-border-color<color>var(--border)
--cui-chart-tooltip-border-width<length>var(--control-rim-width)
--cui-chart-tooltip-radius<length-percentage>var(--radius-md)
--cui-chart-tooltip-shadow*var(--shadow-md)
--cui-chart-tooltip-padding<length-percentage>calc(var(--spacing) * 2.5)
--cui-chart-legend-gap<length-percentage>calc(var(--spacing) * 4)
--cui-chart-swatch-size<length-percentage>calc(var(--spacing) * 2.5)
--cui-chart-swatch-radius<length-percentage>calc(var(--radius-sm) * 0.5)
--cui-chart-animation-duration<time>calc(var(--duration-slow) * 2)
--cui-chart-transition-duration<time>var(--duration-slow)
--cui-chart-easing*var(--ease-emphasized)