Area Chart

A composable area chart with gradient fills, an animated entrance reveal, and an interpolated hover tooltip.

Installation

pnpm add @blakeui/pro-react
npm install @blakeui/pro-react
yarn add @blakeui/pro-react
bun add @blakeui/pro-react

Usage

AreaChart is built on visx for its scales and SVG and the motion library for the entrance reveal and hover animation — it does not use Recharts. Pass a data array (each point has a date plus one numeric field per series) and compose the grid, axes, area series, and tooltip as children using dot notation. Series colors come from the categorical --chart-1 … --chart-5 tokens; the chart's chrome maps onto BlakeUI's neutral tokens automatically.

import {AreaChart} from "@blakeui/pro-react";

const data = [
  {date: new Date(2025, 0, 1), revenue: 12400, costs: 8600},
  {date: new Date(2025, 0, 2), revenue: 13100, costs: 8200},
  // …
];

function App() {
  return (
    <AreaChart data={data}>
      <AreaChart.Grid horizontal />
      <AreaChart.Area dataKey="revenue" fill="var(--chart-1)" name="Revenue" />
      <AreaChart.Area dataKey="costs" fill="var(--chart-2)" name="Costs" />
      <AreaChart.XAxis />
      <AreaChart.YAxis />
      <AreaChart.Tooltip valuePrefix="$" />
    </AreaChart>
  );
}

Anatomy

Import the AreaChart component and access all parts using dot notation.

import {AreaChart} from "@blakeui/pro-react";

<AreaChart>
  <AreaChart.Grid />
  <AreaChart.Area />
  <AreaChart.XAxis />
  <AreaChart.YAxis />
  <AreaChart.Tooltip />
</AreaChart>;

Keyboard & motion

The chart is keyboard-accessible: focus it and use the left/right arrow keys (or Home / End) to move the crosshair across data points. The tooltip and date pill follow, and the active point is announced to screen readers through a live region. The entrance reveal, the value odometer, and the tooltip springs all respect prefers-reduced-motion — when it is set, the chart renders without animation.

Loading state

Set status="loading" to show a skeleton placeholder while data resolves; flip it to "ready" and the chart tweens its y-domain and reveals the series left-to-right. Choose the skeleton treatment with Area's loadingStyle — a pulse segment travelling the stroke, or a soft sweep band.

RevenueCosts
Loading revenue…

API Reference

AreaChart

The root wrapper. Measures its container, builds the time/value scales, and renders the SVG plus the hover layer.

PropTypeDefaultDescription
dataRecord<string, unknown>[]Chart data — one object per point, each with a date field and one numeric field per series.
childrenReactNodeChart parts (AreaChart.Grid, AreaChart.Area,AreaChart.XAxis, …).
xDataKeystring"date"Key in each point holding the x (date) value.
marginPartial<{ top; right; bottom; left }>{ top: 40, right: 40, bottom: 40, left: 40 }Plot margins around the inner chart area.
animationDurationnumber1100Entrance reveal duration in ms (cubic-bezier(0.85, 0, 0.15, 1)).
aspectRatiostring"2 / 1"CSS aspect ratio of the chart box.
status"loading" | "ready""ready"While loading, shows a skeleton and disables interaction. Flipping to ready plays the reveal.
loadingLabelstring""Centered caption shown while loading. Empty string hides it.
yDomainTweenbooleantrueTween the y-domain (skeleton ↔ real data) during a status change instead of snapping.
yDomainTweenDurationnumber500Duration of the y-domain tween in ms.

Also supports all native div HTML attributes.

AreaChart.Area

A gradient-filled series. Add one per metric; the y-domain fits across all series.

PropTypeDefaultDescription
dataKeystringKey in each data point for this series' y values.
fillstring"var(--chart-1)"Gradient fill color (also the default line color).
fillOpacitynumber0.4Fill opacity at the top of the gradient.
gradientToOpacitynumber0Fill opacity at the bottom of the gradient.
strokestringfillLine stroke color.
strokeWidthnumber2Line stroke width.
curveCurveFactorycurveMonotoneXD3 curve interpolation factory.
showLinebooleantrueRender the stroke line on top of the fill.
fadeEdgesbooleanfalseFade the fill at the left/right edges of the plot.
namestringdataKeyLegend/tooltip label for the series.
loadingStrokestring"var(--muted)"Skeleton stroke color while loading.
loadingStrokeOpacitynumber0.5Skeleton stroke opacity while loading.
loadingStyle"pulse" | "sweep""pulse"Skeleton treatment: a travelling pulse segment or a soft sweep band.

AreaChart.Grid

PropTypeDefaultDescription
horizontalbooleantrueRender horizontal grid lines.
verticalbooleanfalseRender vertical grid lines.
numTicksRowsnumber5Number of horizontal lines.
numTicksColumnsnumber5Number of vertical lines.
strokestring"var(--separator)"Line color.
strokeDasharraystringSVG dash pattern. Omit for solid lines.
loadingStrokestringstrokeGrid line color while loading (dimmed to 0.5 opacity).
shimmerbooleanfalseSweep a shimmer band across the grid while loading (pulse mode only).
shimmerStrokestring"var(--muted)"Shimmer band color.
shimmerLengthnumber140Shimmer band length in px.
shimmerSpeednumber1Shimmer speed multiplier (used when shimmerSync is false).
shimmerSyncbooleanfalseLock the shimmer rhythm to the pulse (2.2s traverse + 280ms pause).

AreaChart.XAxis

PropTypeDefaultDescription
numTicksnumber5Approximate number of ticks (always includes the first + last point).
tickFormat(date: Date, index: number) => stringCustom tick label formatter.

AreaChart.YAxis

PropTypeDefaultDescription
numTicksnumber5Approximate number of ticks.
formatLargeNumbersbooleantrueFormat values ≥ 1000 as compact (1200012k).
formatValue(value: number) => stringCustom tick formatter (overrides formatLargeNumbers).
orientation"left" | "right""left"Side of the chart the labels render on.

AreaChart.Tooltip

Declares the hover tooltip — the crosshair, per-series dots, the floating panel with interpolated values, and the date pill. Renders nothing on its own.

PropTypeDefaultDescription
showCrosshairbooleantrueShow the vertical crosshair line.
showDotsbooleantrueShow the per-series dots at the active point.
showDatePillbooleantrueShow the animated date pill under the crosshair.
valuePrefixstringStatic text rendered before each value (e.g. $).

Theming

Series colors are driven by the categorical chart palette (--chart-1 … --chart-5) — set each series' fill. All other chrome maps onto neutral/semantic tokens: grid lines use --separator, the crosshair and axis labels use --muted, and the tooltip panel uses --overlay / --overlay-foreground with --overlay-shadow. Override any token in your theme to restyle the chart.

On this page