← All components
Motion
ComponentsDelta Chip
Delta Chip
How much, and which way.
- CSS layer
- Implemented
- Free to install · MIT
Up 4.2%
onSettle has fired 0 times. The prop can only calm this component further. The switch at the top of the page and your system setting still apply.
Why it moves this way
Most delta badges re-render and that is that. But the moment a metric turns around is exactly when someone should notice. One half-turn of an arrow, 240 ms, is enough. A new number in the same direction only rolls its digits.
Use it
npx shadcn@latest add https://kosh-hazel.vercel.app/r/delta-chip.jsonimport { DeltaChip } from "@/kosh/delta-chip/delta-chip";
<DeltaChip data={4.2} />
// Latency: down is good, so the colours swap. The arrow stays truthful.
<DeltaChip data={-12} suffix=" ms" invert />Add the @kosh registry entry to components.json first, so the CLI can fetch motion-core as well. Then wrap your app in KoshProvider once, and import tokens.css and motion.css in your global stylesheet. Read the setup guide ↗ Read the source ↗
At each motion level
full- When the direction reverses, the arrow turns 180° in 240 ms with a slight overshoot and the two backgrounds cross-fade. The digits roll.
reduced- The arrow swaps without turning. The backgrounds still cross-fade, and the text takes the new direction's colour.
none- Arrow, background and number change at once.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
data | number | required | The signed change. Positive is up. |
format | Intl.NumberFormatOptions | one decimal place | How the size of the change is printed. |
locale | string | "en-US" | Grouping and digit style. |
suffix | string | "%" | Shown after the number. |
invert | boolean | false | For metrics where down is good. Swaps the two backgrounds only. |
flatBelow | number | 0 | Changes this small, or smaller, count as flat: no arrow, no background. |
| Prop | Type | Default | What it does |
|---|---|---|---|
motion | "auto" | "full" | "reduced" | "none" | "auto" | Motion for this component only. The calmest of this prop, the provider and the operating system wins. |
tone | "ink" | "signal" | "muted" | "ink" | Which colour carries the data. |
onSettle | () => void | none | Called once the component has come to rest after an update. |
className | string | none | Added to the root element. |
Theme with CSS variables on any ancestor: --k-delta-good, --k-delta-bad, --k-dur-fade.
Accessibility
- Direction is never colour alone: the arrow shows it and hidden text says “Up 4.2%”.
- With invert, the hidden text still says up or down truthfully. Only the colour changes meaning.
Limits and differences
- The text colour switches at once when the direction turns. The spec delays it to the midpoint of the cross-fade, which would mean animating colour.