Skip to content
Thrum

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-badge

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Props

PropTypeDefaultDescription
valuenumber | nullRequiredThe change against the baseline. With the default format it is a fraction: 0.124 is +12.4%. null when it is unknown.
periodstring–What the change is compared with, for example “vs last week”.
invertbooleanDefault falseA fall is the good direction (churn, latency). It changes the colour of the arrow, never its shape.
formatIntl.NumberFormatOptionsDefault percent, one decimalHow the change is written. Plain data, so a server component can pass it. The sign is always shown.
localestringDefault "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.
classNamestring–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

SourcePro

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. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor