Skip to content
Get Kosh Pro
← All components
Motion

ComponentsDelta Chip

Delta Chip

How much, and which way.

  • CSS layer
  • Implemented
  • Free to install · MIT
Up 4.2%
motion prop

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

PowerShell / install
npx shadcn@latest add https://kosh-hazel.vercel.app/r/delta-chip.json
React / TypeScript
import { 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

Delta Chip props
PropTypeDefaultWhat it does
datanumberrequiredThe signed change. Positive is up.
formatIntl.NumberFormatOptionsone decimal placeHow the size of the change is printed.
localestring"en-US"Grouping and digit style.
suffixstring"%"Shown after the number.
invertbooleanfalseFor metrics where down is good. Swaps the two backgrounds only.
flatBelownumber0Changes this small, or smaller, count as flat: no arrow, no background.
Shared by every Kosh component
PropTypeDefaultWhat 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() => voidnoneCalled once the component has come to rest after an update.
classNamestringnoneAdded 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.