Skip to Content
API referenceAPI reference

API reference

<Waveform>

PropTypeDefaultNotes
samplesreadonly number[]requiredAmplitudes; default range [0, 1].
widthnumberrequiredSVG width.
heightnumberrequiredSVG height.
colorWaveformColor'#000'CSS string or LinearGradientSpec.
renderer'bars' | 'line' | 'area' | fn'bars'Custom: (props: RendererProps) => ReactNode.
inputRange[number, number][0, 1]Re-maps samples into [0, 1].
barWidthnumberautoBars only.
gapnumber1Bars only.
roundedboolean | numberfalseBars only - true = pill, number = explicit radius.
baseline'center' | 'bottom''center'Bars only.
strokeWidthnumber1Line / area.
fillOpacitynumber1Area only.
activeColorWaveformColor-Enables hover / tap highlight; gradients accepted.
activeScalenumber1Bars only - width multiplier for the active bar.
activePushRangenumberautoBars only - neighbours pushed away (linear decay).
activeTransitionMsnumber150Web only - CSS transition duration; native snaps.
onActiveSampleChange(index, sample) => void-index === null on leave / release.

<PlayerWaveform>

Inherits all <Waveform> props, plus:

PropTypeDefaultNotes
progressColorWaveformColor#2563ebPlayed-portion colour; gradients accepted.
progressnumber-01. Takes precedence over positionMs / durationMs.
positionMsnumber-Current playback position in ms.
durationMsnumber-Total duration in ms.
isPlayingbooleanfalseWhen true, progress animates on the UI thread to next frame.
animationDurationnumber200Transition duration between progress values, in ms.

<RecorderWaveform>

Inherits <Waveform> props except samples (you push imperatively), plus:

PropTypeDefaultNotes
capacitynumberautoBar slots in the buffer; computed from width, barWidth, gap if omitted.
initialSamplesreadonly number[]-Optional warm-start data.
transition'scroll' | 'morph''scroll'Slide bars vs animate heights in place.
direction'right' | 'left''right'Edge new samples enter from.
prefillbooleantruePre-fill buffer with zeros so animation starts on first push.
transitionDurationnumber200Per-sample animation duration in ms.
transitionEasingEasingFunction | EasingFactorylinearFrom react-native-reanimated.
fadeInnumber0Bars at the entry edge that fade in (alpha 0→1). Pure opacity.
fadeOutnumber0Bars at the exit edge that fade out (alpha 1→0). Pure opacity.
growInnumber0Bars at the entry edge that grow in height from 0 → full.
growOutnumber0Bars at the exit edge that shrink in height from full → 0.
smoothScrollbooleantruescroll mode only.
scrollDurationnumber-Deprecated - use transitionDuration.
type RecorderWaveformHandle = { push: (amplitude: number | readonly number[]) => void; reset: () => void; };

WaveformColor

type GradientStop = { offset: number; color: string; opacity?: number }; type LinearGradientSpec = { type: 'linear'; /** 'horizontal' (default) = left → right; 'vertical' = top → bottom. */ direction?: 'horizontal' | 'vertical'; /** Two-stop shorthand. Ignored when `stops` is provided. */ from?: string; to?: string; /** Explicit stops; takes precedence over `from` / `to`. */ stops?: readonly GradientStop[]; }; type WaveformColor = string | LinearGradientSpec;

<Waveform> and <PlayerWaveform> paint gradients via SVG <LinearGradient> - any direction and any number of stops is honoured. <RecorderWaveform> uses View.backgroundColor per bar; it samples the gradient once per slot along the x-axis and treats vertical as horizontal sampling. Recorder gradients work best with hex (#rgb, #rrggbb, #rrggbbaa) or rgb(...) / rgba(...) strings; named CSS colours fall back to the nearest stop without interpolation.

Custom renderers

Any function matching (props: RendererProps) => ReactNode can be passed as renderer. The built-in BarsRenderer, LineRenderer and AreaRenderer are also exported if you want to compose them.

import { BarsRenderer, type WaveformRenderer } from 'react-native-waveforms'; const MyRenderer: WaveformRenderer = (props) => ( <BarsRenderer {...props} barWidth={4} rounded /> );