audiocn

Live Waveform

A canvas waveform of a live signal, as scrolling history or the current frame.

Installation

$ pnpm dlx shadcn@latest add @audiocn/live-waveform

Usage

import { LiveWaveform } from "@/components/ui/live-waveform";
<LiveWaveform mode="scrolling" source={analyser.visual} className="h-16" />

The waveform fills its container, so size it with classes. It redraws on resize and picks up theme changes on its own.

Examples

Variants

static bars
static mirror
static line
scrolling line

Idle

With active={false} the waveform shows a dotted line.

Microphone

Theming

Variable or attributeMeaning
--waveformDrawing color, default currentColor
data-mode, data-variantCurrent settings
data-activeDrawing the signal rather than the idle line

Accessibility

The root has role="img". Give it an aria-label, or aria-hidden when a labelled meter is next to it. With reduced motion it redraws four times a second.

API reference

Prop

Type