Message
Chat message primitives with fluid slide-in animations from each bubble's tail.
Message
Chat message primitives with fluid slide-in animations from each bubble's tail.
Hit the re-trigger button to replay the entrance — sent messages surface from the right, received from the left, each springing from its bubble's tail corner.
Installation
Install the component with the Craft-UI Blocks CLI — it drops message.tsx into your project and wires up its runtime dependencies:
npx mvpblocks add messagepnpm dlx mvpblocks add messageyarn dlx mvpblocks add messagebunx mvpblocks add messageFile Structure
The CLI saves the component to your project's components/ui folder:
Import it from @/components/ui/message.
Usage
The primitives compose into a full conversation — group the rows, then lay each message out with its avatar, header, bubble, and footer:
import {
Message,
MessageAvatar,
MessageBubble,
MessageContent,
MessageGroup,
} from "@/components/ui/message";
export function Conversation() {
return (
<MessageGroup>
<Message align="end">
<MessageAvatar>EV</MessageAvatar>
<MessageContent>
<MessageBubble variant="primary">
Deploying to prod real quick.
</MessageBubble>
</MessageContent>
</Message>
<Message>
<MessageAvatar>KD</MessageAvatar>
<MessageContent>
<MessageBubble>It's 4:55 PM. On a Friday.</MessageBubble>
</MessageContent>
</Message>
</MessageGroup>
);
}Theming
Every primitive pulls from your theme tokens, so the conversation matches your app in light and dark mode with no configuration. The default bubble is a muted pill against text-foreground, and the primary bubble flips to bg-primary text-primary-foreground for sent messages — it inverts automatically with your theme. The ghost variant drops the pill entirely (bare text, used for streamed AI replies) and pulls the header/footer padding in with it. Avatars are bg-muted circles, headers and footers use text-muted-foreground, and the sent rows right-align their content and footer while the avatar hugs the bubble's tail — lifting up when a footer sits below.
Animations
- Entrance: on mount, each message slides in from its own side —
align="end"travels +24px from the right,align="start"from the left — while a single spring (stiffness 420, damping 20) drives scale and x together with a short opacity fade. The transform origin sits at the bubble's tail corner, so the scaling reads as the bubble morphing out of its tail rather than the row zooming. - History: pass
animated={false}for messages already on screen so only newly arriving ones animate; without an entrance, rows render withinitial=falseso nothing flashes or hydration-mismatches. - Slide clipping: the group clips horizontal overflow instead of hiding the whole canvas, so a sliding message never flashes a scrollbar while the avatar's footer lift stays visible.
- Reduced motion:
useReducedMotiondrops the entrance entirely — the message just appears.
Props
Message
Prop
Type
MessageBubble
Prop
Type
MessageGroup, MessageAvatar, MessageContent, MessageHeader, MessageFooter
Prop
Type
Registry Bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together. Dependencies: motion.
Contact
If you find any bug or issue, feel free to raise an issue.
Last updated on