Skip to content
caliper ui docs

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.

Free
pnpm dlx shadcn@latest add @caliper/heartbeat-line

Patient monitor

The trace runs at the rate shown.

62bpmHeart rate: 62 beats per minute
Installs components/ui/heartbeat-line.tsxDepends on none beyond ReactMotion none in component source

When 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

terminal
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.

example.tsx
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.

PropTypeDefaultDescription
bpmnumber72Beats per minute; the trace scrolls at exactly this rate.
status"alert" | "steady" | "flatline""steady"Steady is the normal trace, alert turns red and runs as given, flatline draws a still line.
labelstring"Heart rate"Names what is measured, e.g. "Heart rate".
showRatebooleantrueShows the rate as a figure beside the trace.

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.

All Changing values examples