Delta badge
A change said by an arrow, a sign and a word; the tone only repeats it.
import { DeltaBadge, dashboardRatio, dashboardDeltaWay } from "@forgeron/ui";€48.2kup, +12.4%Bettervs last month37up, +9%Worseopen tickets18 daysdown, −14%Better31.4%unchanged, ±0%FlatNew—No comparison
import { DeltaBadge } from "@forgeron/ui";
export default function Default() {
return (
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
<DeltaBadge value="€48.2k" delta={0.124} hint="vs last month" />
<DeltaBadge value="37" delta={0.09} better="down" hint="open tickets" />
<DeltaBadge value="18 days" delta={-0.14} better="down" />
<DeltaBadge value="31.4%" delta={0} />
<DeltaBadge value="New" delta={null} />
</div>
);
}up, +12.4%, Betterdown, −6%, Worseunchanged, ±0%, Flat
// Without the word, it is still read aloud: "up, Better".
import { DeltaBadge } from "@forgeron/ui";
export default function Compact() {
return (
<div style={{ display: "flex", gap: 12 }}>
<DeltaBadge size="sm" showWord={false} delta={0.124} />
<DeltaBadge size="sm" showWord={false} delta={-0.06} />
<DeltaBadge size="sm" showWord={false} delta={0} />
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
delta | number | null | — | A ratio: 0.12 reads +12%. null: nothing to compare with. |
better | "up" | "down" | "up" | Which way is good news: down for open tickets. |
format | (delta: number) => string | +12.4% | Writes the delta. |
value | ReactNode | — | The figure it belongs to. |
hint | ReactNode | — | What it was compared with: vs last month. |
showWord | boolean | true | Better, Worse or Flat after the sign. Off, it is still read aloud. |
size | "sm" | "md" | "md" | Of the badge. |
className | string | — | Extra classes. |