Avara UI

Shadcn Voice Note

A hold-to-record voice note component with dynamic audio waveform bars, slide-to-cancel gesture, and instant playback with a discard option.

Press and hold the pill to record audio in real time. Sliding left cancels the recording, and releasing gives you an instant audio player with waveform seeking and a close/discard option.

Voice Note

Press and hold to record with live animated waveforms, slide left to cancel, and release to preview audio playback with close option.

holdLabel"Hold to record"
label displayed inside the pill during the idle state.
slideCancelLabel"< Slide to cancel"
cancel hint shown underneath the pill during active recording.

Installation

New project? Follow the installation guide to set up Tailwind CSS, shadcn, the cn helper and lucide-react, register the @avara-ui registry once, then copy your styles from the Themes page.

Install Voice Note

npx shadcn@latest add https://avaraui.com/r/voice-note.json

components/custom/blocks/VoiceNoteBlock.tsx is written into your project. Copy any snippet from a Usage tab above and it runs.

Install dependencies

Nothing beyond the shared setup — Voice Note needs only the cn helper and lucide-react, which the installation guide already put in place.

Props Reference

PropTypeDefaultDescription
holdLabelstring"Hold to record"

Label displayed inside the pill during the idle state.

slideCancelLabelstring"< Slide to cancel"

Subtext displayed underneath the pill during active recording.

themeColorstringundefined

Custom theme accent color applied to the play button, active soundwave bars, and pulse indicators.

maxDurationnumber60

Maximum recording duration in seconds before auto-completing.

minDurationnumber0.5

Minimum duration in seconds required to accept the recording. A short tap below this threshold cancels the record immediately.

enableMicbooleantrue

Captures real audio via navigator.mediaDevices when microphone permission is granted.

initialState"idle" | "recording" | "recorded""idle"

Initial visual state for previews and testing.

onRecordStart() => voidundefined

Callback invoked when the user starts holding to record.

onRecordComplete(result: VoiceNoteRecordResult) => voidundefined

Callback invoked when recording successfully finishes.

onCancel() => voidundefined

Callback invoked when recording is cancelled or closed via the 'X' button.