Updated
KPI Tile
Customize
Accent
Days30
Installation
npx shadcn@latest add https://uibrik.com/r/kpi-tile.jsonInstall the packages
npm install @number-flow/react @tabler/icons-react motion react-use-measureAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/kpi-tile/kpi-tile.tsx"use client"; import { useId, useMemo, type PointerEvent } from "react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { cn } from "@/lib/utils"; import { Announce, ChartCard, DataTable, Delta, Headline, useChartCursor, useWidth, areaPath, extent, linear, linePath, nearest, type Point, accentVars, AREA, DOT, DRAW_IN, EASE_OUT,
Adds the files to
components/uibrik/kpi-tile and installs @number-flow/react, @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/kpi-tile.Usage
import { KpiTile } from "@/components/uibrik/kpi-tile/kpi-tile";const format = { style: "currency", currency: "USD", maximumFractionDigits: 0 };<KpiTile title="Revenue" deltaLabel="vs last month" invert={false} area accent="" format={format} // data={[{ label: "…", value: 0 }]} // value={0} // delta={0}/>Where to use KPI Tile
Dashboard headline metrics
A stat with its change and a sparkline gives the key number and its trend together.
Pairs with Area Chart
Revenue and growth summaries
Scrubbing the sparkline rolls the number to any day, answering "what was it last Tuesday".
Pairs with Revenue Dashboard
Admin home pages
A row of tiles is the quickest way to show the health of a product.
Props
KpiTile- title
- Type string
- "Revenue"
- Names the metric.
- deltaLabel
- Type string
- "vs last month"
- What the change is measured against.
- invert
- Type boolean
- false
- Lower is better (churn, latency, cost), so a fall reads as good.
- area
- Type boolean
- true
- Wash under the line.
- accent
- Type string
- ""
- Line colour. Empty uses the chart palette.
- data
- Type { label: string; value: number }[]
- –
- One point per period, oldest first. The last point is the current value.
- value
- Type number
- –
- Headline value. Defaults to the last point.
- delta
- Type number
- –
- Change as a fraction (0.124 is +12.4%). Defaults to the last point against the first.
- format
- Type Intl.NumberFormatOptions
- USD currency
- Formats every number, e.g. { style: "percent" }.
- className
- Type string
- –
- Classes for the outer shell.