Skip to content
caliper ui docs

Pro

Metronome

A pendulum metronome. The arm swings once per two beats and turns at each extreme exactly where the click falls; its weight slides down for faster tempos. The beats of the bar light in turn, the first accented.

Pro
pnpm dlx shadcn@latest add @caliper/metronome

Practice

Press Start, then change the tempo while it runs.

Andante · beats per minute

Stopped

Installs components/ui/metronome.tsxDepends on @radix-ui/react-slot, lucide-reactMotion honours reduced motion

When to use

Use it for

  • Practice tools for musicians, dancers and runners.
  • Any rhythm you want people to feel before they read it.

Skip it when

  • Sample-accurate audio; the click is scheduled per frame, so use a look-ahead scheduler.
  • Decoration with no sound or beat behind it.

Decisions

Why it is built this way, so you know what to keep when you change your copy.

Behaviour

The arm is the beat
The arm's angle is a cosine of the beat count, so it is at an extreme on each beat and moves fastest between them, as a real pendulum does.
Tempo changes keep the phase
Moving the slider while it runs changes the speed from where the arm is, so the beat never restarts.

Usage

Silent until started
The click is off until Start is pressed, can be muted, and the audio context is created by that press.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/metronome

Adds its 4 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source. It is built from Metronome, tapTempo and tempoName.

example.tsx
import { Metronome, tapTempo, tempoName, BPM_MIN, BPM_MAX } from "@/components/ui/metronome"

The worked example comes with Pro

The 23-line example behind the preview opens here, ready to copy.

  • 626 Pro parts, blocks and page templates, all with source
  • $149 once, with lifetime updates. No renewal
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

Metronome

component

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
bpmnumber—
defaultBpmnumber96
onBpmChange((bpm: number) => void)—
beatsnumber4Beats in a bar; the first is accented.
defaultSoundbooleantrueStarts with the click on. It never sounds until Start is pressed.
onBeat((beat: number) => void)—Called on every beat with its position in the bar, from 0.

tapTempo

component

No props of its own; it accepts the native props of its root element.

tempoName

component

No props of its own; it accepts the native props of its root element.

BPM_MIN

helper

A helper exported alongside the component, not a component.

BPM_MAX

helper

A helper exported alongside the component, not a component.

Accessibility

It exposes status semantics, with aria-hidden, aria-label and aria-pressed 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 checks prefers-reduced-motion itself and settles immediately instead of travelling. Every state is still reachable.

All Changing values examples