Trend badge
A small chip for a change against a baseline: an arrow, the signed value and the period it is compared with. Put it beside a figure, in a table cell or under a heading. When the figure and its trend line belong with it, use the stat card.
Install
npx shadcn@latest add @thrum-pro/trend-badgeThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | null | Required | The change against the baseline. With the default format it is a fraction: 0.124 is +12.4%. null when it is unknown. |
period | string | – | What the change is compared with, for example “vs last week”. |
invert | boolean | Default false | A fall is the good direction (churn, latency). It changes the colour of the arrow, never its shape. |
format | Intl.NumberFormatOptions | Default percent, one decimal | How the change is written. Plain data, so a server component can pass it. The sign is always shown. |
locale | string | Default "en-US" | Locale for number formatting. |
surface | "control" | "none" | Default "control" | Glass surface behaviour. Pass "none" for a flat chip embedded inside a card or panel. |
className | string | – | Sets the text size. The arrow follows it. |
Motion and sound
Motion
- First draw: the chip appears complete. Nothing rolls in.
- A new value rolls from the number on screen in about 400 ms with no overshoot. The arrow turns at once.
- While the number rolls the chip is as wide as the wider of the old and the new number. It takes the new width when the roll lands.
- Reduced motion: the new value appears at once.
Sound
Silent. This component makes no sound.
Accessibility
- Direction is an arrow and a sign: “+12.4%” with an arrow up, “-3.1%” with an arrow down, “0.0%” with a level dash. Colour only adds whether that is good news.
- Screen readers hear the direction as a word, then the signed value and the period: “Up +12.4% vs last week”. The arrow is hidden from them.
- A null value prints a dash with no arrow and reads “No data”.
- It is not a live region: a change of value is not announced. Nothing in the chip takes focus.
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/trend-badge.tsx- Packages
motion- Brings along
- Chart foundationsMotion tokensAnimated number
Changelog
- 1.0.0 · 2026-12-03First release.