audiocn

Bar Visualizer

A row of bars driven by frequency bands, with idle, loading and mirrored modes.

Installation

$ pnpm dlx shadcn@latest add @audiocn/bar-visualizer

Usage

import { BarVisualizer } from "@/components/ui/bar-visualizer";
<BarVisualizer aria-label="Voice activity" source={analyser.visual} />

Bars take their color from the text color, so set it with a class such as text-primary. Bars paint on the animation frame without re-rendering React.

Examples

Alignment

center
end
start

Idle and loading

idle decides what bars do without a signal. loading runs a sweep, for connecting or thinking states.

idle pulse
idle wave
loading

Mirrored

Inside a badge

Live

Theming

Variable or attributeMeaning
--bar-widthMaximum bar width, default 0.375rem
--bar-gapGap between bars, default 0.1875rem
--bar-radiusBar corner radius, default fully rounded
data-loadingThe sweep is running
data-indexOn each bar, its position

Accessibility

The root has role="img" and the label "Audio visualizer". Pass aria-label to describe what it shows, or aria-hidden when it is decorative next to a labelled meter.

API reference

Prop

Type