Browse components

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.json

Writes 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.

AudioMessageProps
PropTypeDefault
durationSecondsrequirednumber—
classNamestring—
onPlayToggle() => void—
playingbooleanfalse
progress

Playback position from 0 to 1; bars before it are filled.

number0
unplayed

Turns the unplayed dot on, as WhatsApp marks a new voice note.

booleanfalse
waveform

Bar 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