ReScript Shadcn
Get started
  • Installation
Components
  • Accordion
  • Alert
  • AlertDialog
  • AspectRatio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • ContextMenu
  • DataTable
  • DatePicker
  • Dialog
  • Direction
  • Drawer
  • DropdownMenu
  • Empty
  • Field
  • HoverCard
  • Input
  • InputGroup
  • InputOtp
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • MessageScroller
  • NativeSelect
  • NavigationMenu
  • Pagination
  • Popover
  • Progress
  • RadioGroup
  • Resizable
  • ScrollArea
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • ToggleGroup
  • Tooltip
  • Typography

Message

Displays a message in a conversation, with optional avatar, header, footer, and alignment.

Deploying to prod real quick.
It's 4:55 PM. On a Friday.
It's a one-line change.

The Message component lays out a single message row. It handles the avatar, alignment, header, and footer around the visible message surface. Render the surface with Bubble, and wrap long transcripts with MessageScroller.

Installation#

npx shadcn@latest add @rescript-shadcn/Message

Usage#

<Message>
  <Message.Avatar>
    <Avatar>
      <Avatar.Image src="https://github.com/shadcn.png" alt="@shadcn" />
      <Avatar.Fallback> {"CN"->React.string} </Avatar.Fallback>
    </Avatar>
  </Message.Avatar>
  <Message.Content>
    <Bubble variant=Muted>
      <Bubble.Content> {"How can I help you today?"->React.string} </Bubble.Content>
    </Bubble>
  </Message.Content>
</Message>

Composition#

Message
├── Message.Avatar
└── Message.Content
    ├── Message.Header
    ├── Bubble
    └── Message.Footer

Use Message.Group to stack consecutive messages from the same sender.

Features#

  • Start and end alignment through the align prop
  • Avatar slot anchored to the message row
  • Header and footer slots for sender names, timestamps, and actions
  • Group wrapper for consecutive messages
  • Custom styling through className on every part

Examples#

Avatar#

Use Message.Avatar to render an avatar next to the message. Set align=End to align the row to the end of the conversation.

CN
Something went wrong. Any idea?
ER
I found the failed dependency install.

Group#

Use Message.Group to stack consecutive messages from the same sender.

The class hooks match upstream now.
I also regenerated the registry.
Perfect, update the docs page.

Header and Footer#

Use Message.Header for a sender name and Message.Footer for metadata or actions.

Rhea
I pushed the updated registry item.
2 minutes ago
Looks good from here.

Attachment#

Compose Attachment inside Message.Content to render files attached to a message.

Can you review this file?
release-notes.mdMarkdown - 8 KB
The structure looks right. I left two comments.

Accessibility#

Message is a presentational layout wrapper. Accessibility comes from the content you place inside it. Give icon-only action buttons in Message.Footer an ariaLabel.

API Reference#

Message#

PropTypeDefault
alignStart | EndStart
classNamestring-
@react.component
let make = () =>
  <div className="flex w-full max-w-md flex-col gap-8">
@react.component
let make = () =>
  <div className="flex w-full max-w-md flex-col gap-8">
@react.component
let make = () =>
  <div className="flex w-full max-w-md flex-col gap-8">
@react.component
let make = () =>
  <div className="flex w-full max-w-md flex-col gap-8">
@react.component
let make = () =>
  <div className="flex w-full max-w-md flex-col gap-8">