component
Image Message
A photo that bleeds past the bubble padding, with an optional caption below it.
Install
npx shadcn@latest add https://whatsapp-components.crafter.run/r/image-message.jsonWrites 4 files into your project, and installs clsx and tailwind-merge.
Preview
demos/image-message.tsx
import { ImageMessage } from "@/registry/whatsapp/image-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, 12)} />}
>
<ImageMessage
src="/perfume.svg"
alt="Perfume Violeta"
caption="¿Es este el que tienen?"
/>
</MessageBubble>
<MessageBubble
direction="out"
meta={
<MessageMeta timestamp={new Date(2025, 0, 6, 18, 13)} status="read" />
}
>
<ImageMessage src="/perfume.svg" alt="Perfume Violeta" />
</MessageBubble>
</div>
);
}Props
Read from ImageMessageProps in the component source at build time.
| Prop | Type | Default |
|---|---|---|
srcrequired | string | — |
alt | string | "" |
caption | ReactNode | — |
className | string | — |
flushBleeds the image past the bubble's padding, as WhatsApp does. Turn it off when placing the image somewhere other than directly inside a bubble. | boolean | true |
height | number | — |
width | number | — |
Files
- registry/whatsapp/image-message.tsx
- registry/whatsapp/cn.ts
- registry/whatsapp/whatsapp.css
- LICENSE