Xzero UI
Pro library

KPI drilldownPro

KPI cards that expand into a full detail chart with period comparison and a breakdown table, then fold back.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/kpi-drilldown
Live · keyboard ready

Use this as the overview of an analytics or finance dashboard. Load each metric's series and breakdowns from your warehouse and keep the range in your URL.

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/kpi-drilldown

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { KpiDrilldown } from "@/components/xzero/blocks/kpi-drilldown/kpi-drilldown";

export function Overview({ metrics }: { metrics: Kpi[] }) {
  const [metric, setMetric] = useQueryState("metric");
  return <KpiDrilldown kpis={metrics} selected={metric} onSelectedChange={setMetric} />;
}

API reference

KpiDrilldown

A KPI overview where each card expands into a full detail view on one spring: the label and value stay put while the chart, period comparison, and breakdown table are revealed around them. Ranges morph every sparkline in place.

PropTypeDefaultDescription
kpisKpi[]kpisMetrics: id, label, format, kind (total or rate), lowerIsBetter, daily series, breakdowns by dimension, and a description.
dimensions{ value: string; label: string }[]breakdownDimensionsBreakdown dimensions; values match keys in each metric's breakdowns.
endstring"2026-09-24"ISO date of the last value in every series.
defaultRange"7" | "30" | "90""30"Initial range in days.
selectedstring | null–Controlled open metric id, or null for the grid.
onSelectedChange(id: string | null) => void–Called when a metric opens or closes. Use it to keep the selection in the URL.
titlestring"Overview"Heading.
classNamestring–Class on the root.

Keyboard interactions

KeysAction
Enter / Space on a cardOpens the metric; focus moves to the close button.
EscapeFolds the detail back into its card and returns focus to it.
Arrow left / Arrow rightMoves the chart cursor one day while the chart has focus.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Guidance for AI tools

Blocks are complete, self-contained screens with sample data. Replace the sample data and connect the callbacks described above. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components