Knit UI
GitHub

Playground

Loading playground…

Playground
<AudioVisualizer
  variant="mirror"
  pattern="sine"
/>

Examples

Default

The default mirrored waveform, driven by a smooth travelling sine.

Loading example…

DefaultSourceStorybook

Bars

Vertical bars filled with a linear gradient.

Loading example…

BarsSourceStorybook

Line

A stroked line tracing the level at each point.

Loading example…

LineSourceStorybook

Dots

A dot per bar, sized by level.

Loading example…

DotsSourceStorybook

Wave

A filled, mirrored envelope (smooth waveform area) with a glow.

Loading example…

WaveSourceStorybook

Radial

Spokes radiating from the centre, with a sweep gradient pivoting on the centre.

Loading example…

RadialSourceStorybook

Bursty Ticks

The headline story: a BURSTY, irregular data source (jittery delivery + occasional stalls) — yet the on-screen motion stays smooth because the easing transition is paced on the display clock, not the data clock.

Loading example…

Bursty TicksSourceStorybook

Smoothed

Jumpy per-bar noise, tamed by heavy smoothing — the transition does the work.

Loading example…

SmoothedSourceStorybook

Glow

A soft glow behind a sweep-gradient mirror waveform.

Loading example…

GlowSourceStorybook

Neon

A neon look: a crisp shape with a separate, brightly-tinted blurred halo (glowColor).

Loading example…

NeonSourceStorybook

Vu Meter

VU-meter feel: a snappy attack (peaks pop) with a slow release (a gentle decay tail).

Loading example…

Vu MeterSourceStorybook

Horizontal Gradient

A horizontal gradient running left→right across the bars instead of top→bottom.

Loading example…

Horizontal GradientSourceStorybook

Resting Floor

A resting baseline (floor) so the visualizer always shows a lively bed of bars.

Loading example…

Resting FloorSourceStorybook

Gain

Boosted sensitivity (gain) — quiet input pushed up toward the ceiling and clamped.

Loading example…

GainSourceStorybook

Tinted

A tinted background with a translucent shape (backgroundColor + opacity).

Loading example…

TintedSourceStorybook

Spectrum10 Hz

Loading example…

Spectrum10 HzSourceStorybook

Raw Fft Input

Loading example…

Raw Fft InputSourceStorybook

Target Shared Value

Driven by a target SharedValue instead of the ref handle: write target.value = levels from any JS-thread loop and the visualizer eases toward it. While a target is set the display loop runs continuously (it can't listen to SV writes portably), so prefer the ref push() for the self-suspending path.

Loading example…

Target Shared ValueSourceStorybook

Props

PropTypeDefaultDescription
attacknumber | undefinedRise smoothing `0..1` override — lower = snappier peaks. Defaults to `smoothing`.
backgroundColorstring | undefinedCanvas background color. Default transparent.
colorstring | undefinedSolid fill color (any CSS / RN / Skia color). Ignored when `gradient` is set.
countnumber | undefinedNumber of levels (bars) to render. Default 48.
fftScaleSpectrumInput | undefinedHow `input="fft"` magnitudes are scaled. Default `"byte"` (`AnalyserNode` bytes).
floornumber | undefinedResting baseline `0..1`: lifts every level so the shape never fully collapses (`v → floor + (1 - floor) · v`). Default `0`.
gainnumber | undefinedMultiply incoming levels (sensitivity), clamped to `0..1`. Default `1`.
gapnumber | undefinedGap between bars, px. Default 2.
glownumber | boolean | undefinedA soft glow behind the shape (a Skia blur). `true` applies a tasteful default; a number sets the blur radius in px. Pair with `glowColor` for a tinted halo. Default off.
glowColorstring | undefinedTint for the `glow` halo. When set, the shape stays crisp and a separate blurred layer in this color sits behind it (a neon look). Requires `glow`.
gradient systemstring[] | VisualizerGradient | undefinedA Skia gradient fill — the real payoff of rendering with Skia. Pass an array of colors for a linear gradient, or `{ colors, type }` for control. Overrides `color`.
gradientDirection"vertical" | "horizontal" | undefinedLinear-gradient orientation. Default `"vertical"` (top→bottom).
heightnumber | undefinedVisualizer height in px. Default 48.
input"levels" | "fft" | undefinedWhat the pushed data (`push()` / the `levels` prop) carries. The visualizer keeps only the data its settings need: - `"levels"` (default) — already the final per-bar values. - `"fft"` — RAW FFT magnitudes; push the whole spectrum (256/512/1024 bins) and the component reduces it to `count` log-spaced, dB-normalized bands itself (a memoized `createSpectrumMapper`). Nothing larger than `count` is ever stored or animated. The `target` SharedValue is always treated as final levels.
labelstring | undefinedAccessible label.
levelsnumber[] | undefinedDeclarative fallback: the component pushes this state whenever the value changes. Convenient, but re-renders the component each tick — at high tick rates prefer the ref `push()` handle (Skia Rule 1).
maxBinnumber | undefined`input="fft"`: last magnitude bin to include. Default = pushed length.
maxDbnumber | undefined`input="fft"`: dB mapped to `1` (ceiling). Default `-10`. Ignored for `"byte"`.
minBinnumber | undefined`input="fft"`: first magnitude bin to include (skip DC). Default `1`.
minDbnumber | undefined`input="fft"`: dB mapped to `0` (floor). Default `-90`. Ignored for `"byte"`.
opacitynumber | undefinedOverall opacity `0..1` of the shape. Default `1`.
radius systemnumber | undefinedShape rounding, px (default 2). Its effect is per-variant: corner radius for `bars`/`mirror` rects, and the stroke width for `line`/`radial` (min 1.5). The `dots` and `wave` variants ignore it — dot size tracks the level and the wave envelope is filled, not stroked.
releasenumber | undefinedFall smoothing `0..1` override — higher = a slower VU-meter tail. Defaults to `smoothing`.
responseTimenumber | undefinedRise time constant in MILLISECONDS, overriding the `smoothing`→time mapping. Rate-independent: the same value glides identically whether you push at 10 Hz or 60 Hz — set it (e.g. `90`) to make a sparse/low-rate FFT feed smooth at 60 fps. Release defaults to ~3× this unless `release` is given.
reverseboolean | undefinedReverse the level order (mirror the data left↔right / around the ring).
smoothingnumber | undefinedAttack/release smoothing, `0..1`. `0` snaps to each target; higher values let levels glide and decay. Default `0.3`. Forced to `0` under reduced motion. Use `attack`/`release` to tune the rise/fall halves independently.
targetSharedValue<number[]> | undefinedOptional external target SharedValue. Write `target.value = levels` from your data handler instead of using the ref handle; the loop eases toward it. While a `target` is provided the display loop runs continuously (it can't listen to SV writes portably), so prefer the ref `push()` for the self-suspending path.
variant systemstring | VisualizerVariant | undefined
bars · mirror · wave · line · dots · radial
The visual style: a built-in name (`"bars"`, `"mirror"`, `"wave"`, `"line"`, `"dots"`, `"radial"`), a custom name registered via `registerVisualizerVariant`, or a variant function. Default `"mirror"`.
widthnumber | undefinedFixed width in px. Omit for a responsive `width: "100%"` canvas.
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<AudioVisualizerHandle> | undefined