Twigs Charts
Charts

KPI Chart

The KPI Chart React component displays a key performance indicator value with an optional trend indicator, label, and icon. Ideal for dashboards and summary views.

The KPI Chart component is used to display a single metric value alongside an optional trend indicator showing direction and percentage change.

Usage

import { KPIChart } from "@sparrowengg/twigs-charts";

const Chart = () => {
  return (
    <KPIChart
      value={2953}
      title="New conversations"
    />
  );
};

Props

PropTypeDefault
onClick?
() => void
-
width?
number | string
"100%"
trend?
KPITrend
-
valueFormatter?
(value: number | string) => string
-
suffix?
string
-
prefix?
string
-
icon?
ReactNode
-
title
string
-
value
number | string
-

KPITrend Props

PropTypeDefault
tooltipContent?
ReactNode
-
showTooltip?
boolean
true
label?
ReactNode
-
status?
"positive" | "negative" | "neutral"
-
direction
"up" | "down" | "neutral"
-
percentage
number
-

Examples

With Trend

Negative Trend

Neutral Trend

With Icon

With Prefix

With Value Formatter

Use valueFormatter to fully control how the displayed value is formatted — for example, to abbreviate large numbers.

When valueFormatter is provided, prefix and suffix are ignored. The formatter's return value is used as-is. If you need a currency symbol or unit alongside a custom format, include it directly in the formatter function.

Custom Tooltip

Pass tooltipContent to fully control the tooltip text shown on hover.