Skip to content
Haze UI

Mention input

A native message textarea with filtered @person and #channel suggestions inserted as readable text.

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

When to use

  • A team note should help people find the correct person or channel
  • Mention values can remain ordinary text in the submitted message

When not to use

  • Use textarea when a message has no mention directory
  • Use tags-input when the whole value is a collection of removable tags

Installation

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

pnpm dlx shadcn@latest add @haze/mention-input
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–Unique caller-supplied prefix for this component and its related elements.
namestringidForm submission name.
labelstring"Message"Visible label for the message.
placeholderstring"Write a note. Try @Mira or #design."Example hint inside the textarea.
valuestring""Initial plain message text.
suggestions{ id: string; label: string; kind: "person" | "channel" }[]Two people and two channelsValues inserted after @ or # and their display labels.
rowsnumber3Initial native textarea rows.
disabledboolean–Disables the native control and its enhancement.
classstring–Additional classes for the component root.
...attributesnative control attributes–Other attributes are forwarded to the real form control.

Keyboard interactions

@ or #
Start filtering people or channel suggestions at the current caret.
ArrowUp, ArrowDown, Enter
Move through matching suggestions and insert the highlighted value.
Escape, Tab
Close suggestions without changing the current message.

Accessibility

  • The textarea remains the only editing surface and submits readable mention text without a hidden rich-text model.
  • The enhanced suggestion list announces counts, tracks the active option and leaves focus in the textarea while choosing.
  • The textarea works as an ordinary message field when the enhancement is unavailable.

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 "Mention input" with `npx shadcn@latest add @haze/mention-input`. 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 MentionInput from "@/components/haze/ui/mention-input.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/mention-input.md

  • Customize with real content

    Adapt the Haze mention-input ui for our product. Replace the demo values of these props with our real content: id, name, label, placeholder, value, suggestions, rows, disabled, class, ...attributes. Keep the layout, the heading level rules and these accessibility details: The textarea remains the only editing surface and submits readable mention text without a hidden rich-text model. The enhanced suggestion list announces counts, tracks the active option and leaves focus in the textarea while choosing. The textarea works as an ordinary message field when the enhancement is unavailable. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using mention-input, check it fits: use it when a team note should help people find the correct person or channel; mention values can remain ordinary text in the submitted message. Avoid it when use textarea when a message has no mention directory; use tags-input when the whole value is a collection of removable tags. Alternatives: @haze/textarea, @haze/tags-input, @haze/combobox.

Dependencies

  • @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