Skip to content
GetUrUI

Message Bubble

.md

User and assistant chat bubbles that spring in, group consecutive messages and reveal copy, retry and feedback actions on hover or focus.

aichatmessagebubblethreadfeedback

Installation

$npx shadcn@latest add @geturui/message-bubble
Download source (.zip)

Also installs: Copy Button

Usage

usage.tsx
1import { MessageThread } from "@/components/ai/message-bubble";
2
3export function Thread() {
4  return (
5    <MessageThread
6      messages={[
7        { id: "1", role: "user", content: "Can I change the accent colour?", timestamp: "9:41 AM" },
8        { id: "2", role: "assistant", content: "Yes — update the --volt token.", timestamp: "9:41 AM" },
9      ]}
10      onRetry={(id) => regenerate(id)}
11      onFeedbackChange={(id, value) => track(id, value)}
12    />
13  );
14}

Props

PropTypeDefaultDescription
role*"user" | "assistant"—Sender; sets alignment, colours and the default avatar.
children*ReactNode—Message content.
position"single" | "first" | "middle" | "last""single"Place within a run of messages from the same sender; MessageThread sets this for you.
namestring—Sender name for initials and screen readers.
avatarReactNode—Custom avatar.
timestampstring—Shown under the last bubble of a group.
copyTextstring—Text the copy action copies; defaults to string children.
onRetry() => void—Shows a retry action.
feedback / onFeedbackChange"up" | "down" | null—Controlled thumbs feedback (assistant only).
hideActionsboolean—Hide the actions row.

Accessibility

  • MessageThread is a polite live log, so new messages are announced.
  • Each bubble starts with a visually hidden “Name said:” prefix.
  • Actions appear on hover and on keyboard focus (focus-within), and stay visible on touch devices.
  • Thumbs buttons use aria-pressed.

Related