Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Message for Solid

One turn of a chat in Solid on Ark UI, laid out on the sender's side: an avatar, a bubble or an AI reply, a name or a time, and actions.

On this page11 sections
UI library: Ark UI

Message lays out one turn of a conversation: an avatar, the body, and a line for the name, the time or a few actions, all on the side of whoever sent it. It doesn't color or format the text. Put a person's words in a Bubble, and render an agent's markdown reply straight into the row.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Message anatomy: root, avatar, content, header, bubble, footer

Usage

import {
  Avatar, AvatarFallback, AvatarImage,
} from "@/components/ui/avatar";
import { Bubble, BubbleContent } from "@/components/ui/bubble";
import {
  Message, MessageAvatar, MessageContent,
} from "@/components/ui/message";
<Message>
  <MessageAvatar>
    <Avatar>
      <AvatarImage src="https://github.com/shadcn.png" alt="shadcn" />
      <AvatarFallback>CN</AvatarFallback>
    </Avatar>
  </MessageAvatar>
  <MessageContent>
    <Bubble>
      <BubbleContent>How can I help you today?</BubbleContent>
    </Bubble>
  </MessageContent>
</Message>

Accessibility

Message is layout only: plain div elements with no role, and the side a turn sits on is something people see but a screen reader never says. Give each turn a sender that can be heard, such as a MessageHeader with the name, or visually hidden text like "You said" before the person's own words. An avatar's image needs its own alt, or an empty one when the name is already in text. Every icon-only button in MessageFooter needs a name, which the demos give with aria-label.

Demos

Avatar

Three turns about a failed build, each with a picture in MessageAvatar. The person's question sets align="end", which reverses the row so the picture moves to the end side, and the last reply stacks two bubbles in a BubbleGroup. Show pictures when several people share a thread and the side alone doesn't say who spoke.

Preview width

Group

MessageGroup keeps two turns from one person close together. The first row has an empty MessageAvatar so both bubbles line up, and only the second shows the picture, the way most messengers mark the end of a run. The group adds spacing and nothing else, so each row still sets its own side.

Preview width

Olivia's name sits in MessageHeader above her bubble, and the person's own turn ends with a read receipt in MessageFooter. In a row with align="end", the footer lines its content up on the end side, under the bubble. Use a header to say who spoke when there's no avatar, and a footer for a time or delivery state.

Preview width

Actions

A reply with Copy, Like and Dislike as ghost icon buttons in MessageFooter, and under the person's own turn a failed send, with Retry beside the error. Each button is named with aria-label, and none of them has a handler in this demo. Put actions on replies people will copy or rate, and leave a thread between people without them.

Preview width

Attachment

The person sends a photo in an Attachment above their bubble, and the reply hands back a PDF with a Download button under its text. Attachments sit in MessageContent beside the bubble rather than inside it, so a file card keeps its own shape. The row's align moves both to the same side.

Preview width

Markdown

The reply is three numbered steps with bold text and inline code, drawn by the demo's own small markdown function inside a ghost bubble, which drops the frame and the width cap. The question stays an ordinary bubble. Split it this way when generated answers carry formatting and people's messages are plain text.

Preview width

Pattern

One agent turn: the question in a muted bubble on the end side, and the reply as markdown straight on the row, its install command in a Code Block. Each footer's ghost icon buttons use their label as both name and Tooltip. Both Copy buttons show a check for two seconds, the two ratings toggle aria-pressed, and Retry clears the rating and shows Thinking... briefly before the reply returns.

Preview width

AI SDK

AI SDK UI has no Solid package. To retry a turn, post the conversation up to that turn to your chat route again.

Migrating from AI SDK Elements

AI SDK Elements is for React. In Solid, start from the Pattern demo above: a Message, a Bubble and the footer's buttons are all there is to a turn.

FAQ

How do I put my own chat messages on the right with Message?

Set align to end on Message, and leave the other side's turns on the default, start. The row reverses, which moves the avatar to the end side, and the bubble and footer inside MessageContent line up on that side too. A Bubble in the row needs no align of its own.

End follows the writing direction rather than the screen. In a right-to-left page, the person's own turns sit on the left without any change to your code.

How do I group consecutive messages from the same person?

Wrap the rows in MessageGroup, which stacks them with a small gap and does nothing else. It doesn't merge their bubbles or hide a repeated avatar. Decide that row by row: put the picture on the last row of the run and leave an empty MessageAvatar on the others to keep the bubbles lined up, as the Group demo does.

Start a new group whenever the sender changes. Each row inside still sets its own align.

Where do I put the sender's name and the timestamp in a Message?

The name goes in MessageHeader, above the body, and a time, a read receipt or a delivery state goes in MessageFooter, below it. Both sit inside MessageContent, next to the bubble, so they line up with whichever side the row is on.

The Header and footer demo has both. When a row has an avatar and the name isn't in the header, the image's alt is the only place a screen reader learns who spoke, so give it the name.

How do I render an AI reply's markdown in a Message?

Render it with your own markdown renderer and put the result in MessageContent. Message lays out the row and has no idea what the text is, so headings, lists and code come from the renderer.

Drop it straight into the row, as the Pattern demo does, or wrap it in a Bubble with the ghost variant, as the Markdown demo does, which removes the frame and lets the reply use the whole width. Keep a filled bubble only when the reply is short and should look like chat.

How do I add copy, feedback and retry buttons to an AI message?

Put them in MessageFooter as ghost icon buttons, each with an aria-label, and the footer lines them up on the reply's side. In the Pattern demo, Copy writes the text to the clipboard and shows a check for two seconds, and Good response and Bad response are toggles that set aria-pressed and share one state, so pressing one turns the other off.

The demo's Retry only fakes a new answer with a timer. With the AI SDK, call regenerate with the message's id, as the AI SDK section shows.

Should I use Message or Bubble for a chat UI?

They do different jobs, and most chats use both. Bubble is the colored box around a line of text, and Message is the row around it: the side it sits on, the avatar, and the lines above and below. A bubble alone has no avatar slot, header or footer.

A Bubble on its own is enough for a compact thread with no names or pictures. Reach for Message as soon as a turn needs any of those, or when an agent's reply should sit on the row with no bubble at all.

How do I show a typing indicator under the last chat message?

Put a line under the last row while the other side is writing, and give it role="status" so a screen reader announces it without moving focus. The top demo on this page does that with a Marker, "Oliver is typing...", its text swept by the shimmer class.

Remove the line when the message arrives. Keep its text short, because a status region is read out again each time its text changes.

API Reference

Message

<div> data-slot="message"

PropType
align?"start" | "end"

The side of the conversation it sits on: start (theirs) or end (yours).

Type
"start" | "end"
Default
"start"
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

AttributeType
data-align?string

Mirrors align.

MessageGroup

<div> data-slot="message-group"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

MessageAvatar

<div> data-slot="message-avatar"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

MessageContent

<div> data-slot="message-content"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

MessageHeader

<div> data-slot="message-header"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.

MessageFooter

<div> data-slot="message-footer"

PropType
asChild?(props: ParentProps) => JSX.Element

Render your own element: a function that gets the part's props to spread on it.

Type
(props: ParentProps) => JSX.Element
class?string

Merged with the part's classes.