component
Message Bubble
An incoming or outgoing bubble with the real WhatsApp tail, and a timestamp that tucks into the last line when it fits.
Install
npx shadcn@latest add https://whatsapp-components.crafter.run/r/message-bubble.jsonWrites 5 files into your project, and installs clsx and tailwind-merge.
Preview
¡Hola! ¿Tienen el perfume Violeta?
¡Sí! Nos queda en stock 😍
Sin cola, para los mensajes seguidos del mismo remitente.
demos/message-bubble.tsx
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, 20, 2)} />}
>
¡Hola! ¿Tienen el perfume Violeta?
</MessageBubble>
<MessageBubble
direction="out"
meta={
<MessageMeta timestamp={new Date(2025, 0, 6, 20, 2)} status="read" />
}
>
¡Sí! Nos queda en stock 😍
</MessageBubble>
<MessageBubble direction="out" tail={false}>
Sin cola, para los mensajes seguidos del mismo remitente.
</MessageBubble>
</div>
);
}Props
Read from MessageBubbleProps in the component source at build time.
| Prop | Type | Default |
|---|---|---|
childrenrequired | ReactNode | — |
directionrequired | MessageDirection | — |
className | string | — |
metaMeta is rendered twice on purpose: once hidden inline so the last line of text reserves room for it, once absolutely positioned where it is seen. This is how WhatsApp itself gets the timestamp to sit inside the last line when it fits and drop to its own line when it does not. | ReactNode | — |
tailThe little pointer. Turn it off for grouped follow-up messages. | boolean | true |
Files
- registry/whatsapp/message-bubble.tsx
- registry/whatsapp/types.ts
- registry/whatsapp/cn.ts
- registry/whatsapp/whatsapp.css
- LICENSE