component
Voice Note
An audio message with the sender's avatar and the mic badge that turns blue until it is played.
Install
npx shadcn@latest add https://whatsapp-components.crafter.run/r/voice-note.jsonWrites 7 files into your project, and installs clsx and tailwind-merge.
Preview
0:27
0:41
demos/voice-note.tsx
import { MessageBubble } from "@/registry/whatsapp/message-bubble";
import { MessageMeta } from "@/registry/whatsapp/message-meta";
import { VoiceNote } from "@/registry/whatsapp/voice-note";
export default function Demo() {
return (
<div className="flex flex-col gap-3">
<MessageBubble
direction="in"
meta={<MessageMeta timestamp={new Date(2025, 0, 6, 18, 18)} />}
>
<VoiceNote senderName="Camila" durationSeconds={27} unplayed />
</MessageBubble>
<MessageBubble
direction="out"
meta={
<MessageMeta timestamp={new Date(2025, 0, 6, 18, 20)} status="read" />
}
>
<VoiceNote
senderName="Valeria"
durationSeconds={41}
progress={0.6}
playing
/>
</MessageBubble>
</div>
);
}Props
Read from VoiceNoteProps in the component source at build time.
| Prop | Type | Default |
|---|---|---|
durationSecondsrequired | number | — |
senderNamerequiredSender shown beside the waveform, with the little mic badge. | string | — |
className | string | — |
onPlayToggle | () => void | — |
playing | boolean | — |
progressPlayback position from 0 to 1; bars before it are filled. | number | — |
senderAvatarUrl | string | — |
unplayedTurns the unplayed dot on, as WhatsApp marks a new voice note. | boolean | — |
waveformBar heights from 0 to 1. Falls back to a stable stand-in. | number[] | — |
Files
- registry/whatsapp/voice-note.tsx
- registry/whatsapp/audio-message.tsx
- registry/whatsapp/chat-avatar.tsx
- registry/whatsapp/format-media.ts
- registry/whatsapp/cn.ts
- registry/whatsapp/whatsapp.css
- LICENSE