Component

Waveform

Canvas audio visualization for live analyser nodes, sample arrays, media streams, and low-cost intensity values. Exported from the single package for each framework: @refraction-ui/react and @refraction-ui/astro.

Examples

Bars
Line
Rings
Animate
Color

Installation

$pnpm add @refraction-ui/react

Usage

tsx
import { Waveform } from '@refraction-ui/react'

export function Recorder({ analyserNode }) {
  return (
    <Waveform
      source={analyserNode}
      height={48}
      amplitude={0.75}
      variant="bars"
      barCount={40}
    />
  )
}

Props

PropTypeDefaultDescription
sourceAnalyserNode | MediaStream | Float32Array | number[]--Live analyser, media stream, or sample data source.
samplesFloat32Array | number[]--Precomputed samples for static or replay visualizations.
intensitynumber10 to 1 energy level used for generated animation samples.
amplitudenumber10 to 1 visual waveform height inside the canvas.
variant'bars' | 'line' | 'rings''bars'Visualization style.
heightnumber | string80Canvas box height in px or CSS length.
widthnumber | string'100%'Canvas width in px or CSS length.
barCountnumber48Number of samples rendered by the generated waveform.
smoothingnumber0.8Exponential smoothing factor from 0 to 1.
colorstring'var(--accent-2)'Canvas stroke or fill color.
pausedbooleanfalseFreezes the animation loop.
classNamestring--Additional CSS classes.