Skip to content

Metrics

⋯

The Metrics family renders Line, Area, Bar, Pie, and Bar + Line Combo charts from the Figma sets, and the plot-only .Line Chart Plot used in metric cards. The values, labels, and trends around a plot are documented in Metric Card. Bands and markers draw on the cartesian charts in data coordinates. Each chart uses Nesra tokens and accepts data and labels through a bounded API.

import { AreaChart } from "@nesra/ui/area-chart";
export function DailyVisits() {
return (
<AreaChart
title="Daily visits"
summary="Visits per day. Values are counts."
data={[
{ id: "mon", label: "Mon", values: { visits: 12 } },
{ id: "tue", label: "Tue", values: { visits: 18 } },
]}
series={[{ key: "visits", label: "Visits", color: "orange" }]}
/>
);
}

All five charts are exported from @nesra/ui and their named subpaths. Consumers supply data, series labels, chart token colors, and optional value formatters. The components own their axes, tooltips, legends, and data tables. They do not forward Recharts configuration.

Chart Required data Series definition
Line, Area, Bar Ordered { id, label, values } categories Ordered { key, label, color } entries
Line Chart Plot Ordered { id, label, values } categories Ordered { key, label, color } entries
Combo Ordered { id, label, values } categories One barSeries and one lineSeries
Pie Ordered { id, label, value, color? } slices None

title names the figure. Write summary with the metric and units because the chart cannot infer meaning from the numbers. Data fetching, error text, and interpretation belong to the application.

A color is a ChartColor name that maps to a Nesra token, not an arbitrary CSS color.

Palette color values Token Dark mode
categorical blue, violet, red, orange, teal, yellow, then pink, indigo, purple, neutral. green is also accepted. --nesra-categorical-*-base Uses its Dark token value
mono mono-9 to mono-1 --nesra-chart-mono-1 … 9 Scale reverses: mono-9 turns light
blue blue-1 to blue-6 --nesra-chart-blue-1 … 6 Scale reverses: blue-1 turns dark

The value order in each row is the order a chart assigns by position. The categorical order matches Figma’s chart series: Blue, Violet, Red, Orange, Teal, Yellow. green is left out of that sequence because it reads as a success signal. Mono starts at mono-9, the step with the most contrast against the card. Blue starts at blue-1, like Figma’s filled pie.

A chart assigns palette colors only where it colors by position: single-series BarChart categories and PieChart slices without their own color. Each takes a palette prop that defaults to categorical. Line, Area, Combo, and Scatter series always use their own color, and any ChartColor works there, for example mono-8 for a neutral comparison line.

Charts read every color from tokens, so they follow the .dark class or [data-theme="dark"] without props. In Dark:

  • The card uses surface-card-bg-neutral, and axis text and gridlines use text-support and stroke-border.
  • The mono-* and blue-* scales reverse, so each step keeps its contrast against the card. mono-9 and blue-6 stay the strongest steps.
  • The tooltip is inverse: dark on a light page and light on a dark page. Its swatches keep their series color.
  • The hover marker ring fills with surface-card-bg-neutral, so it matches the card in both modes.
  • Bands and markers use categorical roles, which have their own Dark values. The marker ring uses surface-card-bg-neutral.

Scatter Chart extends this foundation with two numeric axes and optional bubble sizes.

import { LineChart } from "@nesra/ui/line-chart";

Weekly funnel activity

Synthetic example data for a seven-day period.

Visits rise during the week. The three lines show daily counts.

  • Visits
  • Sign-ups
  • Trials
Weekly funnel activity data
CategoryVisitsSign-upsTrials
Mon1244218
Tue1484822
Wed1395325
Thu1735731
Fri1906434
Sat1686128
Sun2037039

The example uses synthetic data. Orange and violet are categorical colors. mono-8 is the monochrome comparison line from Figma. Each series also has a label and a distinct line pattern.

On hover or keyboard focus, Line, Area, and Combo charts show Figma’s .Chart Marker: a 10px ring in the series color with a 2px stroke, filled with surface-card-bg-neutral. A dashed stroke-border-strong guide marks the category. Line series show a line swatch in the tooltip.

import { LineChartPlot } from "@nesra/ui/line-chart";

Engagement

Engagement Engagement sessions from July to October. Synthetic example data.
Engagement data
CategoryEngagement
2026-07-015.10K
2026-07-228.60K
2026-08-087.30K
2026-08-299.80K
2026-09-1516.80K
2026-10-0519.90K
Engagement compared with benchmark Weekly engagement sessions and the benchmark. Synthetic example data.
Engagement compared with benchmark data
CategoryEngagementBenchmark
Week 15.10K6.20K
Week 24.90K6.10K
Week 35.30K6.40K
Week 48.60K6.90K
Week 58.20K7.10K
Week 67.30K7.40K
Week 77.60K7.60K
Week 89.80K8.10K
Week 913.20K8.60K
Week 1016.80K9.20K
Week 1119.90K9.80K

LineChartPlot renders Figma’s .Line Chart Plot: value and category axes, five gridlines, solid lines, and the hover marker and tooltip. It has no title, legend, card surface, or padding. The surrounding card supplies those. size="compact" is 200px tall for metric cards. size="expanded" is 480px tall for the expanded view. showYAxis={false} hides the value labels.

import { AreaChart } from "@nesra/ui/area-chart";

Weekly activity

Synthetic example data.

Daily visits and trials. Values are counts.

X-axis:
Day
Y-axis:
Count
  • Visits
  • Trials
Weekly activity data
CategoryVisitsTrials
Mon2512
Tue3215
Wed3520
Thu3126
Fri3934
Sat5645
Sun6251

Area series overlap independently. Values are not stacked. null leaves a gap. The default legend position is bottom. legendPosition="top" moves it above the plot.

import { BarChart } from "@nesra/ui/bar-chart";

Monthly subscriptions

Synthetic example data.

Plan subscriptions by month. Values are counts.

  • Basic
  • Pro
  • Team
Monthly subscriptions data
CategoryBasicProTeam
January244868
February325272
March395878
April456484

Monthly subscriptions, horizontal

Plan subscriptions by month. Values are counts.

  • Basic
  • Pro
  • Team
Monthly subscriptions, horizontal data
CategoryBasicProTeam
January244868
February325272
March395878
April456484

Basic subscriptions

Basic plan subscriptions by month. Values are counts.

  • January
  • February
  • March
  • April
Basic subscriptions data
CategoryBasic
January24
February32
March39
April45

Basic subscriptions, horizontal

Basic plan subscriptions by month. Values are counts.

  • January
  • February
  • March
  • April
Basic subscriptions, horizontal data
CategoryBasic
January24
February32
March39
April45

Basic subscriptions, monochrome

Basic plan subscriptions by month. Values are counts.

  • January
  • February
  • March
  • April
  • May
  • June
Basic subscriptions, monochrome data
CategoryBasic
January24
February32
March39
April45
May51
June58

orientation="vertical" is the default. One series renders the single-bar design with a color per category from palette. Multiple series render grouped bars with a color per series. Horizontal bars retain input category order. The default legend position is top. legendPosition="bottom" moves it below.

Monthly subscriptions by plan

Synthetic example data.

Total subscriptions by month, split by plan. Values are counts.

  • Basic
  • Pro
  • Team
Monthly subscriptions by plan data
CategoryBasicProTeam
January244868
February325272
March395878
April456484

Visitors by channel

Synthetic example data.

Visitors by acquisition channel, split into new and returning. Values are counts.

  • New visitors
  • Returning visitors
Visitors by channel data
CategoryNew visitorsReturning visitors
Search420310
Social360140
Email90280

stacked renders Figma’s Stacked Bar type. Series stack in order from the baseline, with a 2px gap between segments. Only the outer end of each bar has a 4px radius. Stacked values must be finite and nonnegative. Each series keeps its own color, and the legend lists the series.

import { PieChart } from "@nesra/ui/pie-chart";

Subscriptions by plan

Synthetic example data.

Each slice shows its share of 100 subscriptions.

6 categories

  • Basic10%
  • Pro20%
  • Team5%
  • Enterprise10%
  • Education25%
  • Other30%
Subscriptions by plan data
CategoryValueShare
Basic1010%
Pro2020%
Team55%
Enterprise1010%
Education2525%
Other3030%

Subscriptions by plan, filled

Each slice shows its share of 100 subscriptions.

6 categories

  • Basic10%
  • Pro20%
  • Team5%
  • Enterprise10%
  • Education25%
  • Other30%
Subscriptions by plan, filled data
CategoryValueShare
Basic1010%
Pro2020%
Team55%
Enterprise1010%
Education2525%
Other3030%

variant="outline" renders a donut and may display centerLabel and centerValue. variant="filled" renders a solid pie. Slices without a color take the next palette color. The examples follow Figma: the donut uses categorical and the filled pie uses palette="blue". Data follows input order. Values must be finite and nonnegative. Zero values remain in the table and contribute no slice. Shares are calculated from the total.

import { ComboChart } from "@nesra/ui/combo-chart";

Sign-ups and conversion

Synthetic example data.

Monthly sign-ups are counts; conversion uses the right percentage scale.

  • Sign-ups
  • Conversion rate
Sign-ups and conversion data
CategorySign-upsConversion rate
Jan12012%
Feb9816%
Mar15018%
Apr10522%
May13027%
Jun7231%

barSeries uses the left numeric scale and lineSeries uses the right numeric scale. Format each with formatBarValue and formatLineValue. Include the units in their labels and summary.

import { ChartBand, ChartMarker } from "@nesra/ui/chart-overlay";

Daily visits

Synthetic example data.

Visits per day. Oct 5 is above the expected range of 5,000 to 7,500.

  • Visits
Daily visits data
CategoryVisits
Sep 295,200
Sep 305,600
Oct 16,100
Oct 25,900
Oct 36,400
Oct 47,000
Oct 59,800

Weekly orders

Synthetic example data.

Orders per week. Weeks 3 and 4 ran the spring campaign.

  • Week 1
  • Week 2
  • Week 3
  • Week 4
  • Week 5
Weekly orders data
CategoryOrders
Week 1320
Week 2340
Week 3510
Week 4560
Week 5360

Place ChartBand and ChartMarker as children of LineChart, AreaChart, BarChart, ComboChart, or LineChartPlot. They take data coordinates: a point id for a category and a number for a value. Components that render them, such as a wrapper with preset props, also work.

  • ChartBand axis="value" fills the range between two values across the plot. axis="category" fills from the first category to the last, along the plot. The fill is categorical-{color}-base at 15% opacity, with 1px dashed edges in categorical-{color}-border.
  • ChartMarker with a value draws a dot on that point and a dashed guide down to the category axis. Without a value, it draws only a guide across the plot. active enlarges the dot and shows a halo.
  • Value coordinates use the first value scale: the bar scale in ComboChart and the horizontal scale in a horizontal BarChart. The scale does not grow to include an overlay. A band outside it is clipped to the plot.

Daily visits

Synthetic example data.

Visits per day. Select the Oct 5 marker for details.

  • Visits
Daily visits data
CategoryVisits
Oct 16,100
Oct 25,900
Oct 36,400
Oct 47,000
Oct 59,800

A marker with onClick renders as a focusable button. Enter and Space activate it. Pass ref to anchor a popover to the marker, and set aria-expanded and active while it is open. The marker is not the popover’s trigger, so return focus to it on close with a finalFocus function, as in the example. The application owns the popover content and its open state.

  • The visible summary describes meaning and units. The component does not infer trends from values.
  • Tab to the plot, then use Left and Right Arrow to discover a category’s values in the floating tooltip. Escape dismisses the tooltip. Pointer hover exposes the same values.
  • Every chart includes a visually hidden native table of all categories and series, so screen readers can read each value. Missing values read “No value.” Figma does not define a visible data disclosure, so the table has no visible control.
  • Keep series labels meaningful. Colors supplement labels. Line Chart also uses distinct line patterns.
  • The lightest mono-* and blue-* steps sit close to the card color. Use them next to stronger steps, as in a pie, rather than as the only mark in a plot.
  • The plot and the Scatter plot show the shadow-nesra-focus-ring ring on keyboard focus.
  • Pie charts list every slice and its share beside the plot. Their native table includes exact values and shares. Consumers should keep labels concise and distinct.
  • LineChartPlot has no visible title. label names the figure, and summary describes it for screen readers. Like the full charts, it carries every value in a visually hidden native table.
  • Overlays add a text line each after the hidden table, such as “Expected range: 5,000 to 7,500.” A marker’s label is its accessible name. Write it with the date and meaning, such as “Anomaly on Oct 5.”
  • A marker without onClick is a labelled image and not a Tab stop. With onClick, it is a button after the plot in Tab order and shows the effects-focus-ring ring on keyboard focus.
  • Plot and tooltip animations follow the user’s reduced-motion preference. When reduced motion is requested, values and hover states appear without animation.
  • Verify the summary and values against the application’s actual data. The consuming application owns data fetching, error copy, and any important interpretation of the trend.

Line, Area, Bar, and Combo use ordered { id, label, values } rows. Point IDs and series keys must be nonempty and unique. Every point needs a value for every series key. Each value must be finite or null. null means missing, never zero. Pie slice IDs must also be nonempty and unique. All five charts accept figure attributes except the native title and children props, which their own layout controls.

These props apply to Line, Area, Bar, Combo, and Pie. Each chart renders a visually hidden native data table when values are available.

Prop Type Default Effect
title string required Visible heading and accessible figure name.
summary string required Visible meaning and units, written by the consumer.
description string — Supporting text beneath the title.
loading boolean false Shows loading status and sets aria-busy.
error string | null — Shows consumer-supplied error text instead of a plot.
className string — Adds or overrides outer figure classes.

Empty data renders an empty status. A consumer supplies status text through error when data fetching fails.

Line, Area, Bar, and Combo also accept the axis legend props from Figma’s .Chart Legend:

Prop Type Default Effect
xAxisLabel string — Shows “X-axis:” in text-support, then this name in text-body.
yAxisLabel string — Shows “Y-axis:” in text-support, then this name in text-body.

The axis legend sits above the series legend, in Body/XSmall Regular, and renders only for the labels given. The “X-axis:” and “Y-axis:” prefixes are translatable through NesraI18nProvider.

Prop Type Default Effect
data LineChartPoint[] required Ordered { id, label, values } categories. IDs must be unique. Each series key needs a finite number or null.
series LineChartSeries[] required At least one ordered { key, label, color } definition. Keys must be unique.
formatValue (value: number) => string String Formats ticks, tooltip values, and table cells.
formatCategory (label: string) => string identity Formats category ticks, tooltip labels, and table row headings.
children ReactNode — ChartBand and ChartMarker overlays. Their text is listed after the hidden data table.

null creates a gap. It never means zero. Empty data and data with only missing values show an empty status. The categorical horizontal scale follows input order. The vertical numeric scale includes zero. The plot fills its container. Other native figure attributes are forwarded.

Prop Type Default Effect
data ChartPoint[] required Ordered categories with one value per series.
series ChartSeries[] required Ordered area labels and chart colors.
formatValue (value: number) => string String Formats ticks, tooltip values, and table cells.
formatCategory (label: string) => string identity Formats category labels and table row headings.
legendPosition "top" | "bottom" "bottom" Places the legend above or below the plot.
children ReactNode — ChartBand and ChartMarker overlays.

Areas overlap independently and are not stacked. null leaves a gap. AreaChart inherits the shared chart props and forwards native figure attributes other than title and children.

Prop Type Default Effect
data ChartPoint[] required Ordered categories with one value per series.
series ChartSeries[] required One series colors categories. Multiple series group bars.
orientation "vertical" | "horizontal" "vertical" Chooses bar and category-axis direction.
palette "categorical" | "mono" | "blue" "categorical" Colors each category when there is one series.
formatValue (value: number) => string String Formats ticks, tooltip values, and table cells.
formatCategory (label: string) => string identity Formats category labels and table row headings.
legendPosition "top" | "bottom" "top" Places the legend above or below the plot.
stacked boolean false Stacks series into one bar per category, from the baseline.
children ReactNode — ChartBand and ChartMarker overlays.

stacked throws for a negative value. Horizontal bars keep input category order. BarChart inherits the shared chart props and forwards native figure attributes other than title and children.

Prop Type Default Effect
data ChartPoint[] required Ordered categories with bar and line values.
barSeries ChartSeries required Bar label, color, and left numeric scale.
lineSeries ChartSeries required Line label, color, and right numeric scale.
formatBarValue (value: number) => string String Formats left ticks, bar tooltip and table values.
formatLineValue (value: number) => string String Formats right ticks, line tooltip and table values.
formatCategory (label: string) => string identity Formats category labels and table row headings.
legendPosition "top" | "bottom" "bottom" Places the legend above or below the plot.
children ReactNode — ChartBand and ChartMarker overlays.

The bar and line scales include zero independently. Hovering a category draws Figma’s Detail Line: a dashed stroke-border-strong line through the middle of the category, like Line and Area. As in Figma, it sits above the bars and the line. The line’s hover ring stays above it. Bar charts shade the hovered category with foundation-bg-gray instead. ComboChart inherits the shared chart props and forwards native figure attributes other than title and children.

Prop Type Default Effect
data PieChartPoint[] required Ordered { id, label, value, color? } slices.
variant "outline" | "filled" "outline" Renders a donut or solid pie.
palette "categorical" | "mono" | "blue" "categorical" Colors slices that have no color, in data order.
centerLabel string — Places a label inside the outline donut.
centerValue string — Places a value inside the outline donut.
formatValue (value: number) => string String Formats tooltip and table values.

Pie values must be finite and nonnegative. Zero values remain in the table but contribute no slice. A zero total renders an empty status. The table includes exact values and computed shares. PieChart inherits the shared chart props and forwards native figure attributes other than title and children.

Prop Type Default Effect
label string required Accessible figure name. Not displayed.
summary string required Meaning and units, for screen readers only.
data LineChartPoint[] required Ordered { id, label, values } categories, as in LineChart.
series LineChartSeries[] required Ordered { key, label, color } lines.
size "compact" | "expanded" "compact" Total height: 200px or 480px, including the category axis.
showYAxis boolean true Shows the value axis labels.
formatValue (value: number) => string String Formats value ticks, tooltip values, and hidden table cells.
formatCategory (label: string) => string identity Formats category ticks, tooltip labels, and hidden table headings.
children ReactNode — ChartBand and ChartMarker overlays.

The plot fills its container width. Data with only missing values shows an empty status at the same height. LineChartPlot forwards native figure attributes other than title and children. It has no loading or error state. The surrounding card owns those.

Prop Type Default Effect
axis "value" | "category" required Chooses value or category coordinates for from and to.
from number for value, string for category required Range start: a value, or a point id.
to number for value, string for category required Range end: a value, or a point id. Either order works for values.
label string required Meaning of the range. Listed with the data as “label: from to to.”
color CategoricalColor "neutral" Fill categorical-{color}-base at 15% and edges categorical-{color}-border.

Values must be finite. A category id that is not in data throws. The band is hidden from assistive technology inside the plot because its text is listed with the data.

Prop Type Default Effect
category string required Point id of the marked category.
value number — Draws the dot at this value. Omit it for a guide across the plot.
label string required Accessible name and annotation text.
color CategoricalColor "neutral" Dot, guide, and halo colors. See below.
active boolean false Enlarges the dot from 14px to 18px and shows a 24px halo.
onClick SVG click handler — Makes the marker a focusable button that Enter and Space activate.
ref Ref<SVGGElement> — Receives the marker group, for example as a popover anchor.

A categorical color uses categorical-{color}-strong for the dot, -border for the guide, and -subtle-hover for the halo. neutral uses icon-muted, stroke-border, and foundation-bg-disabled, which are Figma’s neutral (Event) marker roles. The dot has a 2px surface-card-bg-neutral ring. ChartMarker forwards other SVG group attributes and event handlers, such as aria-expanded.

Both overlays throw outside a cartesian chart. PieChart and ScatterChart do not accept them.

ChartColor, ChartPalette, ChartMonoColor, ChartBlueColor, and CategoricalColor are exported as types from @nesra/ui. ChartBandProps, ChartValueBandProps, ChartCategoryBandProps, ChartMarkerProps, and LineChartPlotProps are also exported.

See colors, typography, layout, and shape and elevation for the token contract.

Not available yet

Other chart types have no supported Nesra UI import yet.