Voice Note

A mic button that opens into a recording bar with a live waveform.

Preview

"use client";

import { VoiceNote } from "@/components/agents/voice-note";

export function VoiceNoteUsage() {
  return (
    <VoiceNote
      className="max-w-sm"
      onRecordStart={() => {
        // Start your MediaRecorder here and pass its level to `level`.
      }}
      onSend={(durationMs) => {
        // Stop the recorder and upload the clip; durationMs is its length.
        void durationMs;
      }}
    />
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/voice-note

API Reference

level?
number | MotionValue<number>

Live input level from 0 to 1 while recording, as a number or a MotionValue. Without it the waveform idles softly.

Default—
onRecordStart?
(() => void)

Called when recording starts. Start your recorder here; the component never opens the microphone.

Default—
onDiscard?
(() => void)

Called when the recording is thrown away, from the discard button or Escape.

Default—
onSend?
((durationMs: number) => void)

Called with the recording's length in ms when it is sent.

Default—
maxDuration?
number

Stops recording and sends once it reaches this length, in seconds. Default: no limit

Default—
disabled?
boolean

Blocks starting a recording. Default: false

Defaultfalse
labels?
Partial<{ record: string; send: string; discard: string; recording: string; sent: string; }>

Override any built-in string, e.g. for translation.

Default—
className?
string

Classes merged onto the root element.

Default—

Updated