Skip to content
Haze UI

Message

One chat message with avatar, author, time, actions and a sending, sent, delivered, read or failed state. Bubble or plain row.

pnpm dlx shadcn@latest add @haze/message
Open preview in a new tab
Livesmall script

When to use

  • Building a chat or support thread from single messages instead of the ready-made chat-thread panel
  • An AI transcript where each reply carries copy, retry or rating buttons
  • A sent message that can fail and needs a visible retry

When not to use

  • You want a complete panel with a message box. Use chat-thread.
  • Entries are comments with replies and reactions under a post. Use comment-thread.

Installation

Add the Haze registry to components.json once, then install Message with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/message
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Id of the article; the author name gets `${id}-author` and names it.
namestring"Mira"Author name; also the source of the avatar initials.
role"user" | "assistant" | "system""assistant"User is right-aligned in the bubble look, assistant left-aligned, system a centered note without avatar.
roleLabelstring–Short visible text after the name, such as "You" or "Support assistant".
appearance"bubble" | "plain""bubble"Bubble puts the text on a surface; plain is a full-width transcript row.
timestring–ISO date-time for the time element. Pass a fixed value, never the current time.
timeLabelstring–Time as it reads, such as "09:41".
status"sending" | "sent" | "delivered" | "read" | "failed"–Delivery state, shown as an icon and text under the message. Sent is a check, delivered a muted double check, read a foreground double check. Change data-status on the status line (the element with data-message-status) to swap the state; the icon pops in.
statusLabels{ sending: string; sent: string; delivered: string; read: string; failed: string }{ sending: "Sending…", sent: "Sent", delivered: "Delivered", read: "Read", failed: "Not sent" }Text for each delivery state.
actionsLabelstring"Message actions"Accessible name of the group around the actions slot.
classstring–Extra classes on the article.
...restHTML attributes–Passed to the article.
default slotslot–The message content.
actionsslot–Small ghost icon buttons such as copy, retry or rate, each with an aria-label.
retryslot–A button shown next to the text when status is failed.

Keyboard interactions

Tab
Move through the buttons in the actions and retry slots.

Accessibility

  • Each message is an article named by its author, so a screen reader announces who wrote it before the content. Put the articles inside a list or a role="log" container; the component does not add the list item itself.
  • The time is a time element with a datetime value.
  • Delivery state is an icon plus text (Sending, Sent, Delivered, Read, Not sent), never color alone. The status line is a polite live region with a screen-reader text that follows data-status, so a state change is read once; the icons are hidden from assistive technology and the pop is skipped under reduced motion.
  • Action buttons are your own, and each needs an aria-label because they show only an icon. They sit in a group named by actionsLabel.
  • This one component covers both a message and a bubble: appearance switches between the two looks, and the markup is the same.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Message" with `npx shadcn@latest add @haze/message`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Message from "@/components/haze/ui/message.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/message.md

  • Customize with real content

    Adapt the Haze message ui for our product. Replace the demo values of these props with our real content: id, name, role, roleLabel, appearance, time, timeLabel, status, statusLabels, actionsLabel, class, ...rest, default slot, actions, retry. Keep the layout, the heading level rules and these accessibility details: Each message is an article named by its author, so a screen reader announces who wrote it before the content. Put the articles inside a list or a role="log" container; the component does not add the list item itself. The time is a time element with a datetime value. Delivery state is an icon plus text (Sending, Sent, Delivered, Read, Not sent), never color alone. The status line is a polite live region with a screen-reader text that follows data-status, so a state change is read once; the icons are hidden from assistive technology and the pop is skipped under reduced motion. Action buttons are your own, and each needs an aria-label because they show only an icon. They sit in a group named by actionsLabel. This one component covers both a message and a bubble: appearance switches between the two looks, and the markup is the same. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using message, check it fits: use it when building a chat or support thread from single messages instead of the ready-made chat-thread panel; an ai transcript where each reply carries copy, retry or rating buttons; a sent message that can fail and needs a visible retry. Avoid it when you want a complete panel with a message box. use chat-thread.; entries are comments with replies and reactions under a post. use comment-thread.. Alternatives: @haze/chat-thread, @haze/comment-thread, @haze/marker.

Dependencies

  • npm: @lucide/astro
  • @haze/avatar
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog