Skip to content
Haze UI

Composer

Message box for a chat or comment thread: a growing textarea, optional file chips, a send button, a key hint and a counter.

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

When to use

  • The reply box under a chat, comment or ticket thread
  • A short message that sends on Enter and may carry file attachments
  • An app where Enter should add a line and Cmd/Ctrl+Enter sends

When not to use

  • A longer form field with a fixed height. Use textarea.
  • The user must mention people with @ while typing. Use mention-input.
  • You need the whole conversation panel with bubbles. Use chat-thread.

Installation

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

pnpm dlx shadcn@latest add @haze/composer
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–Textarea id. The hint and attach input ids derive from it.
namestring–Field name posted with the form. Defaults to id.
actionstring–Where the form posts. Omitted by default: the form then has no action or method attribute, so apps intercept the haze:composer-send event and call preventDefault on submit, or pass an action.
method"get" | "post""post"Form method.
placeholderstring"Write a message…"Placeholder of the empty box.
labelstring"Message"Screen-reader label of the textarea.
valuestring–Initial text.
maxRowsnumber6The box grows to this many lines, then scrolls.
submitOn"enter" | "mod-enter""enter"Which keys send. Cmd/Ctrl+Enter always sends; Shift+Enter always adds a line in enter mode.
hintstring–Line under the box explaining the keys.
maxLengthnumber–Limits the text and shows a counter.
attachbooleanfalseShows the attach button and lists chosen files as chips with remove buttons.
acceptstring–Accepted file types for the attach input.
fileNamestring–Name of the file input. Defaults to <id>-files.
sendLabelstring"Send"Accessible name of the send button.
attachLabelstring"Attach files"Accessible name of the attach button.
removeLabelstring"Remove"Start of each chip remove button's name; the file name follows.
attachedLabelstring"Attached files"Name of the file list and start of the spoken count.
counterLabelstring"Character limit"Screen-reader text before the limit.
classstring–Extra classes on the form.
actionsslot–Extra buttons after the attach button, such as an emoji picker.

Keyboard interactions

Enter
Send (submitOn "enter") or add a line (submitOn "mod-enter").
ShiftEnter
Add a line.
CmdEnterCtrlEnter
Send in both modes.
Tab
Move between the box, attach button, chips' remove buttons and Send.

Accessibility

  • The textarea has a visually hidden label. The hint is linked with aria-describedby.
  • Enter never sends while an IME composition is open, so people typing in Japanese, Chinese or Korean keep their text.
  • The send button is disabled while the box is empty or only whitespace; without scripts it stays enabled and the browser requires text.
  • Attached files form a list. Removing a chip moves focus to the next chip, and a status line announces the count.
  • The counter turns red and bold at the limit, and its number is always shown, so it never relies on color.

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 "Composer" with `npx shadcn@latest add @haze/composer`. 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 Composer from "@/components/haze/ui/composer.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/composer.md

  • Customize with real content

    Adapt the Haze composer ui for our product. Replace the demo values of these props with our real content: id, name, action, method, placeholder, label, value, maxRows, submitOn, hint, maxLength, attach, accept, fileName, sendLabel, attachLabel, removeLabel, attachedLabel, counterLabel, class, actions. Keep the layout, the heading level rules and these accessibility details: The textarea has a visually hidden label. The hint is linked with aria-describedby. Enter never sends while an IME composition is open, so people typing in Japanese, Chinese or Korean keep their text. The send button is disabled while the box is empty or only whitespace; without scripts it stays enabled and the browser requires text. Attached files form a list. Removing a chip moves focus to the next chip, and a status line announces the count. The counter turns red and bold at the limit, and its number is always shown, so it never relies on color. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using composer, check it fits: use it when the reply box under a chat, comment or ticket thread; a short message that sends on enter and may carry file attachments; an app where enter should add a line and cmd/ctrl+enter sends. Avoid it when a longer form field with a fixed height. use textarea.; the user must mention people with @ while typing. use mention-input.; you need the whole conversation panel with bubbles. use chat-thread.. Alternatives: @haze/textarea, @haze/mention-input, @haze/chat-thread.

Dependencies

  • npm: @lucide/astro
  • @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