Skip to Content
Kokonut UI

CD-13Cards

Metric Card

A revenue KPI card. Scrub a day, drag a range, or pick a segment; the number rolls, the line morphs and the breakdown follows.

Install with
no extra packages

PROBuilding a billing page? Billing and Usage is in Kokonut UI Pro

Installation

Metric Card is a free, open-source React component in the Kokonut UI Cards collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/metric-card.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/metric-card

Usage

import MetricCard from "@/components/kokonutui/metric-card";

export default function Example() {
  return <MetricCard />;
}

Props

label
stringDefault "Revenue"
segments
string[]Default ["Plans", "Usage", "Services"]

Names of the parts that add up to the metric.

data
MetricPoint[]Default built-in

Daily values, oldest first. Needs twice the longest period, so each period has one to compare with.

events
MetricEvent[]Default built-in

Days worth a note, such as a launch or a price change. Pinned on the chart.

periods
number[]Default [7, 30, 90]
defaultPeriod
numberDefault 30
format
"currency" | "number"Default "currency"
currency
stringDefault "USD"
className
string

Extra classes for the root element.

MetricPoint

daterequired
string

YYYY-MM-DD

partsrequired
number[]

One value per segment, in the order of segments.

MetricEvent

daterequired
string

YYYY-MM-DD

labelrequired
string

Dependencies

NeedsVersionComes from
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.