Skip to content
GitHub (opens in a new tab)
AnalyticsBlock

KPI board

The top of a dashboard: three to six KPIs, a chart for the one you pick, and its top rows.

What a block is

A block is a kit component for a whole area of a screen, built only from other kit components and tokens. You import it like any component; nothing is copied into your app. Put it inside your page’s <main>: it brings no header or nav of its own.

When to use

  • the first row of an analytics or reporting dashboard
  • compare a few KPIs and drill into one without leaving the page
  • one range (7 / 30 / 90 days) should change cards, chart and table together

When not to use

  • only a strip of numbers: Scoreboard
  • one chart on its own: LineChart or BarChart
  • a full dataset to search and filter: DataTable
  • more than six KPIs: a Scoreboard (it wraps) and a separate chart

Usage

Three to six KPIs sit in a selectable Scoreboard, the only picker (five or six wrap; on a phone they go two by two): the chart and the table of top rows follow the one marked Charted. Deltas read Better or Worse. One range control changes all of them.

import { KpiBoard } from "agentic-ds-kit";

export function Dashboard({ metrics, series, rows }) {
  return (
    <main className="layout-content">
      <KpiBoard
        metrics={metrics}        // { id, label, goodWhen?, values: { [range]: { value, delta?, hint? } }, columns }[]
        series={series}          // series[metricId][range]: { label, value }[]
        rows={rows}              // rows[metricId][range]: DataTable rows, each with an id
        ranges={[
          { value: "7d", label: "7 days" },
          { value: "30d", label: "30 days" },
          { value: "90d", label: "90 days" },
        ]}
        defaultRange="30d"       // or range + onRangeChange
        defaultSelectedMetric="revenue" // or selectedMetric + onSelectedMetricChange
      />
    </main>
  );
}

Layout

  • top: heading beside the range SegmentedControl
  • then the selectable Scoreboard of KPIs: appearance cards; below --grid-breakpoint-sm (40rem) of block width it turns divided and four go two by two; five or six wrap
  • then the LineChart beside the DataTable, in layout-split--primary
  • the block is its own inline-size container; below --grid-breakpoint-md (64rem) of block width the table stacks under the chart

Props

NameTypeRequiredDefaultNotes
metricsarrayYes—3–6 of { id, label, goodWhen?, values: Record<range, { value, delta?, trend?, deltaTone?, hint? }>, columns: DataTableColumn[], rowsTitle?, rankBy? }. Values are pre-formatted strings; a range with no entry shows a dash. goodWhen (up for MRR, down for overdue or churn) makes the delta read Better or Worse. hint is the muted text after the delta, e.g. "vs Oct"; default "last <range label>".
seriesobjectYes—series[metricId][range]: ChartDatum[] ({ label, value }) for the LineChart.
rowsobjectYes—rows[metricId][range]: DataTableRow[] (each with id). Ranked by the metric's rankBy column, highest first, then cut to rowLimit.
rangesarrayYes—{ value, label }[], two to four, e.g. Month / Quarter / Year. Ranges are data, not an enum.
rangestringNo—Controlled range value.
defaultRangestringNo—Uncontrolled starting range. Default the first.
onRangeChangefunctionNo—(range) => void
selectedMetricstringNo—Controlled metric id for the chart and table.
defaultSelectedMetricstringNo—Uncontrolled starting metric. Default the first.
onSelectedMetricChangefunctionNo—(metricId) => void
rowLimitnumberNo5How many top rows the table shows.
descriptionstringNo—Line under the heading.
titlestringNoKey metrics—

Built from

  • Component
    →

    Scoreboard

    Metrics strip of kit Scorecards: two to six figures, and the only metric picker.

  • Component
    →

    Line

    Change and progress over ordered samples as a line or area chart.

  • Component
    →

    Bar

    Compare magnitudes across categories with vertical or horizontal bars.

  • Component
    →

    DataTable

    Framed dataset with search, filters, column settings, and a caption title.