VoiceNote

VoiceNote is an animated voice note component for React Native and React, from the dissolve library. Voice message bubble: play, scrub the waveform with ticks, unsend as dust.

A voice message bubble. Play and pause, the played part of the waveform takes the ink, drag along it to seek. Long press to unsend: the bubble blows away as dust. No audio dependency, playback is a timer you hook to your player.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add voice-note --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/voice-note.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add voice-note --web
npx shadcn@latest add https://dissolve.rselmi.com/r/voice-note.json

Usage

VoiceNote.tsx (React Native)
import { VoiceNote } from '@/components/dissolve/voice-note';

<VoiceNote
  mine
  duration={9}
  seed="msg-42"
  onPlay={() => player.play()}
  onPause={() => player.pause()}
  onUnsend={() => remove(id)}
/>
VoiceNote.tsx (React)
import { VoiceNote } from '@/components/dissolve/voice-note';

<VoiceNote
  mine
  duration={9}
  seed="msg-42"
  onPlay={() => player.play()}
  onPause={() => player.pause()}
  onUnsend={() => remove(id)}
/>

Props

PropTypeDefaultDescription
durationnumberrequiredLength of the note in seconds. Playback is simulated with a timer.
levelsnumber[]Loudness per sample, 0 to 1. Resampled to the number of bars that fit.
seednumber | string1Generates a deterministic, speech like waveform when levels is not given.
minebooleanfalseYour own message: accent bubble with white content. Otherwise a surface bubble.
widthnumber248Bubble width.
onPlay / onPause / onEnd() => voidHook your audio player here.
onUnsend() => voidCalled once the bubble has dissolved: remove it from your data here.
unsentbooleanfalseFlip to true to unsend from outside (a menu, a swipe).
unsendOnLongPressbooleantrue with onUnsendLong press the bubble (480 ms) to unsend.
presetVariantName'dust'Exit used when the note is unsent.
hapticsbooleantrueLight impact on play, a tick per bar while seeking.
classNamestringBubble: background, radius, padding.
buttonClassNamestringPlay and pause button.
labelClassNamestringTime label.

Source

Previous: ReactionPicker · Next: SignaturePad · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.