Skip to content
Get Kosh Pro
← All components
Motion

ComponentsLive Spark

Live Spark

A new point slides in. The line moves along.

  • Motion layer
  • Implemented
  • Free to install · MIT

Latest 51

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

Swapping the whole path on every tick makes the line shimmer and hides the one thing that changed: the newest point. Sliding keeps every old point recognisable, so the eye only has to read the right edge.

Use it

PowerShell / install
npx shadcn@latest add https://kosh-hazel.vercel.app/r/live-spark.json
React / TypeScript
import { LiveSpark } from "@/kosh/live-spark/live-spark";

const [points, setPoints] = useState([12, 18, 15, 22, 19]);

<LiveSpark data={points} window={24} />

// A point arrives: append it
setPoints([...points, 27]);

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
The drawing slides left by one step per new point (about 380 ms, no overshoot) and the end dot pops. When the vertical range changes, the line eases to its new scale instead of being redrawn. Points arriving mid-slide extend the same slide: the line never jumps back.
reduced
No slide. The line is simply in its new place, and the end dot fades in.
none
The line is in its new place.

Props

Live Spark props
PropTypeDefaultWhat it does
datanumber[]requiredThe series, oldest first. Append to it, or pass a sliding window: both are recognised as points arriving.
windownumber24How many points are visible. Older points leave on the left.
domain[number, number]range of visible points, padded 10%A fixed vertical range.
heightnumber48Reserved height in px. The width is always 100% of the parent.
showLastbooleantrueA signal-coloured dot at the newest point.
labelstringlatest value and trendThe accessible description.
curve"linear" | "smooth""linear"Straight segments, or a curve through every point that never overshoots between two of them.
enterbooleanfalseIf the line is off screen at load, it is revealed left to right as it scrolls into view.
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-spark-stroke, --k-spark-dot, --k-tone.

Accessibility

  • It is one image whose label carries the summary: the latest value and whether the visible stretch is up, down or steady.
  • It does not announce updates. If it updates on a timer, give people a pause control.

Limits and differences

  • With curve="smooth", the last segment is reshaped slightly when the next point arrives, because a curve's shape at a point depends on its neighbours.
  • d3-shape is still not a dependency: the curve is about forty lines in the component.