Working with data
Data shapes, missing values, formatting numbers, server components.
Data components (charts, numbers, meters, live feeds and dashboards) take plain serialisable data props: numbers, strings, arrays and objects, with no render props and no formatter functions. That keeps the rules consistent across every visualisation and lets a server component pass its data straight down. Interactive UI primitives (dialogs, menus, cards, tabs and forms) use standard composable JSX parts instead. This page covers data shapes, missing values, number formatting, and large series.
Data shapes
A chart of one series takes its points as data, in the order they are drawn: oldest first for a series over time. The calendar heatmap places each day by its date, so its data can be in any order. A chart of several series takes labels and series. A component that shows one figure takes a value. The table lists every required prop except the label or title.
| Component | Prop | Type |
|---|---|---|
| Choice card | ChoiceCard: value | string |
| Combobox | ComboboxItem: value | ComboboxOption |
| Inline edit | aria-label | string |
| Input OTP | InputOTPSlot: index | number |
| Mask input | mask | string |
| Multi select | options | readonly MultiSelectOption[] |
| Radio group | RadioGroupItem: value | string |
| Select | SelectItem: value | string |
| Copy button | value | string |
| Icon button | aria-label | string |
| Segmented control | options | readonly SegmentedControlOption[] |
| Toggle group | ToggleGroupItem: value | string |
| Command palette | CommandItem: children | ReactNode |
| Confirm popover | children | ReactElement |
| Context menu | ContextMenuRadioItem: value | string |
| Dropdown menu | DropdownMenuRadioItem: value | string |
| Hover card | HoverCardTrigger: href | string |
| Menubar | MenubarRadioItem: value | string |
| Navigation menu | NavigationMenuLink: href | string |
| Notification center | notifications | readonly NotificationItem[] |
| Pagination | pageCount | number |
| Stepper | StepperItem: title | ReactNode |
| Table of contents | items | readonly TableOfContentsItem[] |
| Tabs | TabsTrigger: value | string | number |
| Tabs | TabsContent: value | string | number |
| Data table | columns | readonly DataTableColumn[] |
| Data table | rows | readonly DataTableRow[] |
| Data table | caption | string |
| Diff viewer | before | string |
| Diff viewer | after | string |
| Filter bar | fields | readonly FilterField[] |
| JSON viewer | value | JsonValue |
| Kbd | Shortcut: keys | string |
| Sortable list | items | readonly SortableItem[] |
| Transfer list | items | TransferItem[] |
| Tree view | items | readonly TreeNode[] |
| Virtual list | items | readonly VirtualListItem[] |
| Chat message | ChatMessageTime: dateTime | Date | string |
| Chat message | ChatMessageFile: name | string |
| Chat message | ChatMessageStatus: status | "sending" | "sent" | "failed" |
| Image zoom | src | string |
| Image zoom | alt | string |
| QR code | value | string |
| Reasoning panel | steps | readonly ReasoningStep[] |
| Tool call card | name | string |
| Animated number | value | number |
| Stat card | value | number |
| Trend badge | value | number | null |
| Area chart | data | readonly AreaChartPoint[] |
| Bar chart | data | readonly BarChartPoint[] |
| Bar list | data | readonly BarListItem[] |
| Bullet chart | measures | readonly BulletChartMeasure[] |
| Calendar heatmap | data | readonly CalendarHeatmapDay[] |
| Category bar | data | readonly CategoryBarSegment[] |
| Chart legend | items | readonly ChartLegendItem[] |
| Chart tooltip | ChartTooltip: x | number |
| Chart tooltip | ChartTooltip: y | number |
| Chart tooltip | ChartTooltip: width | number |
| Chart tooltip | ChartTooltipRow: label | ReactNode |
| Chart tooltip | ChartTooltipRow: value | ReactNode |
| Chart tooltip | ChartTooltipTotal: value | ReactNode |
| Cohort grid | periods | readonly string[] |
| Cohort grid | cohorts | readonly CohortGridCohort[] |
| Combo chart | labels | readonly string[] |
| Combo chart | bars | readonly ComboChartSeries[] |
| Donut chart | data | readonly DonutChartSegment[] |
| Funnel chart | data | readonly FunnelChartStage[] |
| Heatmap | rows | readonly string[] |
| Heatmap | columns | readonly string[] |
| Heatmap | values | readonly (readonly (number | null)[])[] |
| Histogram | values | readonly (number | null)[] |
| Line chart | labels | readonly string[] |
| Line chart | series | readonly LineChartSeries[] |
| Live chart | data | readonly LiveChartPoint[] |
| Metric comparison | current | number | null |
| Metric comparison | previous | number | null |
| Radar chart | axes | readonly string[] |
| Radar chart | series | readonly RadarChartSeries[] |
| Radial bar chart | data | readonly RadialBarChartItem[] |
| Scatter chart | series | readonly ScatterChartSeries[] |
| Sparkline | data | readonly (number | null)[] |
| Stacked bar chart | labels | readonly string[] |
| Stacked bar chart | series | readonly StackedBarChartSeries[] |
| Status tracker | data | readonly StatusTrackerBlock[] |
| Treemap | data | readonly TreemapNode[] |
| Waterfall chart | data | readonly WaterfallChartStep[] |
| Gauge | value | number | null |
| Progress bar | value | number | null |
| Ring meter | value | number |
| Usage meter | used | number |
| Usage meter | limit | number |
| Activity feed | items | readonly ActivityFeedItem[] |
| Image compare | before | ReactNode |
| Image compare | after | ReactNode |
| Marquee | children | ReactNode |
| Text scramble | children | string |
| Text shimmer | children | ReactNode |
| Ticker tape | items | readonly TickerTapeItem[] |
| App shell | workspace | AppShellWorkspace |
| App shell | groups | readonly AppShellNavGroup[] |
| Chat thread | messages | readonly ChatThreadMessage[] |
| Finance dashboard | data | FinanceDashboardData |
| KPI grid | items | readonly KpiGridItem[] |
| Metric table | columns | readonly MetricColumn[] |
| Metric table | rows | readonly MetricRow[] |
| Metric table | caption | string |
| Onboarding checklist | steps | readonly OnboardingStep[] |
| Ops monitoring dashboard | data | OpsMonitoringData |
| SaaS metrics dashboard | data | SaasMetricsDashboardData |
| Sales dashboard | data | SalesDashboardData |
| Support dashboard | data | SupportDashboardData |
| Web analytics dashboard | data | WebAnalyticsDashboardData |
Where the type has a name, it is exported from the component's file. The area chart's point, for example:
type AreaChartPoint = {
label: string; // axis name
value: number | null; // null = gap
};[
{ label: "Mon", value: 120 },
{ label: "Tue", value: 180 },
{ label: "Wed", value: null },
{ label: "Thu", value: 260 },
]The page of each component has its shape and a sample next to the full list of props. Every chart and graphic also needs a label that says what the data measures.
You should see
A component never throws on awkward data. An empty list shows “No data” in a chart (set your own text with emptyLabel). One point, a flat series and negative values all draw.
Missing values
A missing value is null. The line breaks there and resumes at the next real value. Nothing is drawn across the gap, because a line through it would show a reading that was never taken.
const data = [
{ label: "Mon", value: 120 },
{ label: "Tue", value: null }, // no reading on Tuesday
{ label: "Wed", value: 260 },
];- Do not send
0for “no reading”. Zero is a reading, and the chart draws it. - Do not send
NaNorundefined. Convert them tonullwhere you load the data. - A gap can be the first or the last point. In the area chart, a point with a gap on both sides is drawn as a dot.
- In readouts and in the data table, a missing value is written as a dash.
Formatting numbers
Pass format, an Intl.NumberFormatOptions object. The component applies it everywhere it writes a number: on the axis, in the readout, and in the table for screen readers.
<AreaChart
data={data}
label="Response time"
format={{ style: "unit", unit: "millisecond" }}
/>These are common options, with what they print:
| format | Value, and what prints |
|---|---|
Default: compactnot set | 1283112.8K |
Currency{ style: "currency", currency: "USD" } | 12831$12,831.00 |
Currency, compact{ style: "currency", currency: "USD", notation: "compact" } | 12831$13K |
Whole currency{ style: "currency", currency: "EUR", maximumFractionDigits: 0 } | 12831€12,831 |
Percent{ style: "percent", maximumFractionDigits: 1 } | 0.18418.4% |
Plain, with separators{ maximumFractionDigits: 0 } | 1283112,831 |
Unit{ style: "unit", unit: "millisecond" } | 412412 ms |
Unit, one decimal{ style: "unit", unit: "gigabyte", maximumFractionDigits: 1 } | 1.5361.5 GB |
Another locale{ style: "currency", currency: "EUR" }locale="de-DE" | 12831.512.831,50 € |
- With no
format, numbers are compact with at most one decimal. - A percent value is a fraction: pass
0.184for 18.4%. - Put the unit in
formator inlabel, so a number never stands alone. formatis an object, not a function, so it can cross from a server component to the browser.
Locale, and why it is fixed
Numbers are formatted for en-US unless you pass locale. The default is fixed on purpose. A component renders twice, once on the server and once in the browser, and both must print the same text. If each side used its own default locale, a server in one country and a visitor in another would print “12,831” and “12.831”, and React would report a hydration mismatch.
To format for your visitor, decide the locale once, on the server (from the URL, the account or the request), and pass the same string to every component: locale="de-DE".
Passing data from a server component
Component files start with "use client", and every data prop is serialisable. Load the data in a server component and pass it down:
// app/dashboard/page.tsx: a server component
import { AreaChart } from "@/components/ui/area-chart";
import { getDailyRevenue } from "@/lib/queries"; // your own data access
export default async function Page() {
const rows = await getDailyRevenue();
const data = rows.map((row) => ({ label: row.day, value: row.total }));
return (
<AreaChart
data={data}
label="Revenue"
format={{ style: "currency", currency: "USD", notation: "compact" }}
className="h-64"
/>
);
}- Shape the data on the server. Send the chart only
labelandvalue, not whole database rows: everything you pass is sent to the browser. - Callbacks such as
onActiveChangeare the one kind of prop a server component cannot pass. Use them from a client component. - A chart with axes draws once it has measured its container in the browser. Before that it holds its final size, empty, so nothing moves when the data appears.
Large series
- Components are built to draw from 2 to 500 points. A chart has more points than pixels long before that causes trouble: at 600 px wide, 500 points is already less than 2 px each.
- Every point is a segment of the line and a row in the hidden data table. A series of many thousands makes both heavy, and a screen reader user has to move through all of it.
- There is no built-in down-sampling. Aggregate where the data lives: minutes into hours, hours into days. Choose the step so the chart gets a few hundred points at most.
- Axis names thin themselves to what fits. The area, line and stacked bar charts always keep the first and the last; the bar chart keeps the first and then every few. The cursor still stops on every point.
- When new data has the same number of points, the shape morphs. When the number changes, the chart switches at once. For a live series, keep a fixed window (the last 60 readings) to get the morph.