Hey! How are you doing today?
Installation
$ pnpm dlx shadcn@latest add @mcpcn/message-bubble
Usage
import {
MessageBubble,
MessageBubbleContent,
} from "@/components/ui/message-bubble";<MessageBubble>
<MessageBubbleContent />
</MessageBubble>Composition
Use the following composition to build an MessageBubble:
MessageBubble
└── MessageBubbleContentExamples
Image Messages
Check out this view!
"use client";
import { ImageMessageBubble } from "@/components/ui/message-bubble";
export function MessageBubbleImageDemo() {
return <ImageMessageBubble />;
}With Reactions
We just hit 10,000 users!
"use client";
import { MessageWithReactions } from "@/components/ui/message-bubble";
export function MessageBubbleReactionsDemo() {
return <MessageWithReactions />;
}Voice Messages
"use client";
import { VoiceMessageBubble } from "@/components/ui/message-bubble";
export function MessageBubbleVoiceDemo() {
return <VoiceMessageBubble />;
}OpenUI Integration
Install the OpenUI React packages.
pnpm add @openuidev/react-lang zodAdd MessageBubble to a component library and map it to the installed component.
import { createLibrary, defineComponent } from "@openuidev/react-lang";
import { z } from "zod/v4";
import {
MessageBubble,
MessageBubbleContent,
} from "@/components/ui/message-bubble";
const OpenUIMessageBubble = defineComponent({
name: "MessageBubble",
description:
"Chat message bubbles with text, image, voice, and reaction variants.",
props: z.object({}),
component: () => (
<MessageBubble>
<MessageBubbleContent />
</MessageBubble>
),
});
export const message_bubbleLibrary = createLibrary({
root: "MessageBubble",
components: [OpenUIMessageBubble],
});For richer generated compositions, define the child primitives separately and connect them with .ref fields. See Defining Components in the OpenUI documentation.
json-render Integration
Install the json-render React packages.
pnpm add @json-render/core @json-render/react zodAdd MessageBubble to a component catalog and map it to the installed component.
import { defineCatalog } from "@json-render/core";
import { defineRegistry } from "@json-render/react";
import { schema } from "@json-render/react/schema";
import { z } from "zod";
import {
MessageBubble,
MessageBubbleContent,
} from "@/components/ui/message-bubble";
export const catalog = defineCatalog(schema, {
components: {
MessageBubble: {
props: z.object({}),
description:
"Chat message bubbles with text, image, voice, and reaction variants.",
},
},
});
export const { registry } = defineRegistry(catalog, {
components: {
MessageBubble: () => (
<MessageBubble>
<MessageBubbleContent />
</MessageBubble>
),
},
});Use catalog.prompt() to constrain model output, then render the generated spec with the json-render React Renderer. See the json-render Quick Start for the provider and streaming setup.
API Reference
See the Base UI documentation for more information.