component
Audio Message
Play button, waveform and duration. Controlled playback, so it stays server-renderable.
Install
npx shadcn@latest add https://whatsapp-components.crafter.run/r/audio-message.jsonWrites 5 files into your project, and installs clsx and tailwind-merge.
Preview
0:27
1:35
demos/audio-message.tsx
import { AudioMessage } from "@/registry/whatsapp/audio-message";
import { MessageBubble } from "@/registry/whatsapp/message-bubble";
import { MessageMeta } from "@/registry/whatsapp/message-meta";
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)} />}
>
<AudioMessage durationSeconds={27} unplayed />
</MessageBubble>
<MessageBubble
direction="out"
meta={
<MessageMeta timestamp={new Date(2025, 0, 6, 18, 19)} status="read" />
}
>
<AudioMessage durationSeconds={95} progress={0.45} playing />
</MessageBubble>
</div>
);
}Props
Read from AudioMessageProps in the component source at build time.
| Prop | Type | Default |
|---|---|---|
durationSecondsrequired | number | — |
className | string | — |
onPlayToggle | () => void | — |
playing | boolean | false |
progressPlayback position from 0 to 1; bars before it are filled. | number | 0 |
unplayedTurns the unplayed dot on, as WhatsApp marks a new voice note. | boolean | false |
waveformBar heights from 0 to 1. Falls back to a stable stand-in. | number[] | DEFAULT_WAVEFORM |
Files
- registry/whatsapp/audio-message.tsx
- registry/whatsapp/format-media.ts
- registry/whatsapp/cn.ts
- registry/whatsapp/whatsapp.css
- LICENSE