Skip to Content
Components<Waveform>

<Waveform>

Static renderer. Pass an array of amplitudes in [0, 1] (or any range remapped via inputRange) and the component draws bars, a line, or an area chart.

Quick example

import { Waveform } from 'react-native-waveforms'; <Waveform samples={amplitudes} width={320} height={80} color="#2563eb" gap={2} rounded />

Renderers

<Waveform samples={amplitudes} renderer="bars" gap={2} rounded /> <Waveform samples={amplitudes} renderer="line" strokeWidth={1.5} /> <Waveform samples={amplitudes} renderer="area" fillOpacity={0.85} />

Hover / tap interaction

Setting activeColor turns on the hit overlay. On web you get hover; on native, tap & drag. The active bar can grow (activeScale) and push its neighbours away (activePushRange).

<Waveform samples={amplitudes} width={320} height={80} color="#2563eb" activeColor="#f97316" activeScale={1.8} activeTransitionMs={180} onActiveSampleChange={(index, value) => { // index === null on leave / release }} />

Gradient fills

color and activeColor accept a WaveformColor (CSS string or LinearGradientSpec). See the API reference for the full type.

<Waveform samples={amplitudes} width={320} height={80} color={{ type: 'linear', from: '#3b82f6', to: '#a855f7' }} />

Props

PropTypeDefaultDescription
samplesreadonly number[]requiredAmplitudes; default range [0, 1].
widthnumberrequiredSVG width in px.
heightnumberrequiredSVG height in px.
colorWaveformColor'#000'CSS string or LinearGradientSpec.
renderer'bars' | 'line' | 'area' | fn'bars'Built-in name or a custom (props: RendererProps) => ReactNode.
inputRange[number, number][0, 1]Re-maps samples from another range (e.g. dBFS) into [0, 1].
barWidthnumberautoBars only - explicit bar width; auto-fits when omitted.
gapnumber1Bars only - px gap between bars.
roundedboolean | numberfalseBars only - true for pill, number for explicit corner radius.
baseline'center' | 'bottom''center'Bars only - vertical anchor.
strokeWidthnumber1Line / area only.
fillOpacitynumber1Area only.
activeColorWaveformColor-Enables hover / tap highlight; gradients accepted.
activeScalenumber1Bars only - width multiplier for the active bar.
activePushRangenumberautoBars only - how many neighbours get pushed aside (linear decay). Auto-4 when activeScale > 1.
activeTransitionMsnumber150Web only - CSS transition for active state. Native snaps.
onActiveSampleChange(index, sample) => void-Fires on hover / tap. index === null on leave / release.

Playground

Loading playground…