Chart

Chart frame with optional title, description, toolbar, loading and empty states, plus legend and tooltip helpers.

Also known as: chart frame, plot, data chart, legend

Installation

Install with the CLI, or copy the component source into your project.

Add chart (npm)

npx --yes -p @default-file/ui df-ui add chart

Default

ChartFrame wraps a caller supplied plot. Title, description, and plotLabel name the graphic. ChartLegend lists the series below.

Weekly output
Items published and left as drafts this week.
  • Published
  • Drafts

Toolbar

Pass actions through toolbar. They align with the title in the header.

Output
Published and draft items this week.
  • Published
  • Drafts

Loading

loading replaces children with a skeleton at the plot height.

Weekly output
Items published and left as drafts this week.

Empty

empty shows the kit empty copy. emptyContent replaces that message.

Weekly output
Items published and left as drafts this week.
No data
Weekly output
Custom empty copy for a quiet range.
No activity in this range.

Sizes

sm, md, and lg set the plot height step. md is the default.

Weekly output
Plot height follows the size step.
  • Published
  • Drafts

Tooltip

ChartTooltip is a presentational helper. Pass active, label, and payload. formatValue formats each value.

Wednesday
  • Published15 items
  • Drafts8 items

Properties

Chart frame, legend, and tooltip helpers for kit plots. Compose ChartFrame around the graphic, then ChartLegend and ChartTooltip as needed.

ChartFrame

PropTypeDefaultNotes
titleReactNode-Header title above the plot.
descriptionReactNode-Supporting copy under the title. Wired as aria-describedby on the plot when the plot has a name.
toolbarReactNode-Actions aligned with the header.
plotLabelstring-Accessible name for the plot. Prefer a short summary of the data. When omitted, a string title is used. Provide plotLabel or a string title so the graphic is not unnamed.
size"sm" | "md" | "lg""md"Plot height step.
loadingbooleanfalseShow the loading placeholder instead of children.
emptybooleanfalseShow emptyContent instead of children.
emptyContentReactNode-Content when empty is true.
childrenReactNode-Plot graphic when not loading or empty.
classNamestring-Additional styles on the frame.

ChartLegend

PropTypeDefaultNotes
itemsreadonly ChartLegendItem[]-Legend rows. Each item has id, label, and optional color.
classNamestring-Additional styles on the list.

ChartTooltip

PropTypeDefaultNotes
activeboolean-Whether the tooltip is shown.
labelReactNode-Tooltip heading.
payloadreadonly ChartTooltipPayloadItem[]-Series rows shown in the tooltip body.
formatValue(value, item) => ReactNode-Optional formatter for each payload value.
classNamestring-Additional styles on the tooltip.