audiocn

Smooth Waveform

One clean line across the width that follows the sound, as a flowing wave or an oscilloscope trace.

Installation

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

Usage

import { SmoothWaveform } from "@/components/ui/smooth-waveform";
<SmoothWaveform
  aria-label="Voice activity"
  className="text-primary h-24"
  source={analyser.visual}
/>

The line takes its color from the text color. It is the plain version of the electric waveform: the same shape, with no crackle, glow or sparks.

The waveform fills its container, so size it with classes. It paints on the animation frame without re-rendering React, redraws on resize and picks up theme changes on its own.

Examples

Wave and scope

wave draws a smooth wave shaped by the frequency bands, calm enough for a voice assistant. scope draws the signal itself, like an oscilloscope, and starts each frame on a rising zero crossing so steady tones stand still.

wave
scope

Idle and loading

With no signal the line rests flat. loading runs a pulse along it, for connecting or thinking states.

idle
loading

Microphone

Theming

Variable or attributeMeaning
--waveformLine color, default currentColor
data-modewave or scope
data-activeThe signal is above the floor
data-loadingThe loading pulse is running

Accessibility

The root has role="img" and the label "Audio waveform". Pass aria-label to describe what it shows, or aria-hidden when it is decorative next to a labelled meter. With reduced motion the wave stops drifting and the line redraws four times a second.

API reference

Prop

Type