Components
Heartbeat line
A live monitor trace. The line scrolls past a fixed edge at the true rate, so a faster rate is really a faster line. Alert turns it red; flatline stops the scroll and draws a level line.
pnpm dlx shadcn@latest add @caliper/heartbeat-lineWhen to use
Use it for
- Heart rate, device check-ins, server pulse and anything that beats.
- Status rows where a single dot does not say how alive something is.
Skip it when
- Exact readings over time; use `Sparkline` or a chart.
- Decoration with no data behind it.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- Speed is the rate
- The trace is six beats wide and slides three beats per cycle, so the loop has no seam and the cycle length is exactly three beats at the given rate.
Styling
- Colour for state
- Green while steady, red for an alert, grey when flat; the rate and state are also written as text.
Usage
- Read as a sentence
- A status reads "Heart rate: 72 beats per minute"; the drawing is hidden from assistive technology.
Installation
pnpm dlx shadcn@latest add @caliper/heartbeat-line
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above.
import { useState, type ReactNode } from "react" import { Button } from "@/components/ui/button" import { HeartbeatLine } from "@/components/ui/heartbeat-line" function Panel({ title, context, className = "max-w-md", children }: { title: string; context: string; className?: string; children: ReactNode }) { return ( <section className={`grid w-full gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting max-sm:p-4 ${className}`}> <div className="grid gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {children} </section> ); } const rhythms = [ { id: "rest", label: "Resting", bpm: 62, status: "steady" as const }, { id: "run", label: "Running", bpm: 148, status: "steady" as const }, { id: "alert", label: "Alert", bpm: 176, status: "alert" as const }, { id: "flat", label: "No signal", bpm: 0, status: "flatline" as const }, ]; export function HeartbeatLineDemo() { const [index, setIndex] = useState(0); const rhythm = rhythms[index]; return ( <Panel title="Patient monitor" context="The trace runs at the rate shown."> <div className="grid justify-items-center rounded-control bg-muted py-6"> <HeartbeatLine bpm={rhythm.bpm || 60} status={rhythm.status} label="Heart rate" /> </div> <div className="flex flex-wrap gap-2" role="group" aria-label="Rhythm"> {rhythms.map((item, at) => ( <Button key={item.id} variant={at === index ? "default" : "secondary"} size="sm" aria-pressed={at === index} onClick={() => setIndex(at)}> {item.label} </Button> ))} </div> </Panel> ); }
API reference
HeartbeatLine
component
Also accepts the native props of its root element and a ref.
Accessibility
It exposes status semantics, with aria-hidden kept in step with state. Changes that matter are announced through a live region.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.
Related
- SparklineA tiny trend line with no axes, for use inside text and tables.
- Live indicatorWhether a feed is live, in words and a dot. The dot sends out a soft ring only while live, blinks while reconnecting and rests otherwise, and gives one extra ring for each update you tell it about.
- Signal linesStacked signal traces, each a quiet line with a burst of peaks in the middle, drawn front to back so every line hides the ones behind it like a ridge in mist. The peaks drift and breathe, and the pointer raises a swell on the lines beneath it.