StatCard

A key metric with its change versus the previous period, an optional icon and a small chart.

Status: beta. Category: Data display.

import { StatCard } from '@glyphui/ui'

Exports: StatCard, statCardStyles.

Notes

  • trend sets the arrow and color. Use invertTrend for metrics where down is good, such as churn or latency.

Example: Dashboard row

import { StatCard } from '@glyphui/ui'
import { DollarSign, Timer, Users } from 'lucide-react'

export default function Example() {
  return (
    <div className="grid gap-4 sm:grid-cols-3">
      <StatCard
        label="Revenue"
        value="$48,210"
        delta="12.4%"
        trend="up"
        icon={<DollarSign />}
        description="vs. last month"
      />
      <StatCard label="Active users" value="3,912" delta="4.1%" trend="up" icon={<Users />} />
      <StatCard
        label="p95 latency"
        value="182 ms"
        delta="9%"
        trend="down"
        invertTrend
        icon={<Timer />}
      />
    </div>
  )
}

Example: With a chart

Pass any chart or sparkline to chart; it is colored with the primary color.

import { StatCard } from '@glyphui/ui'
import { Sparkline } from '@glyphui/ui/chart'

const values = [12, 14, 13, 17, 16, 19, 18, 22, 21, 25, 27, 30]

export default function Example() {
  return (
    <StatCard
      className="max-w-xs"
      label="Monthly recurring revenue"
      value="$30,400"
      delta="8.2%"
      trend="up"
      chart={<Sparkline title="Monthly recurring revenue over 12 months, rising" values={values} />}
    />
  )
}

Live page: https://glyphui.xyz/components/stat-card