Data
Delta
How a value moved against the one before it: an arrow, a sign and the change, with the direction in words for screen readers. Color only says whether that is good news, so spending going up can be red. A percentage needs a positive base: from zero or below it shows the difference in value. A first value reads new, and a missing one is a dash with the reason in a Tooltip.
Preview
percent
Up +20%Up +20%Down −20%No change 0%
amount and from zero
Down −$25.80Up +$50.00
new and no data (hover the dash)
newNo comparison: August has not synced yet
Installation
// Resolves dependencies, copies the source, and installs npm packages automatically.
Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| current, previous | number | null | - | Minor units for money |
| format | "percent" | "amount" | "number" | "percent" | The change as a share, in money, or as a plain number |
| intent | "increase-is-good" | "increase-is-bad" | "neutral" | "increase-is-good" | Which way is good news |
| currency, locale | string | - | Fall back to the FormatProvider's |
| reason | string | - | Why there is nothing to compare |
| size | "sm" | "md" | "md" | 10px or 12px |
| variant | "text" | "pill" | "text" | A pill sits on a soft tint of its tone, for a Metric or a tile |
| labels | { up?, down?, flat?, new?, none? } | - | Every word |
| compareValues(current, previous) | { state, difference, ratio } | - | The same comparison as data |