WebberUI

Mention Textarea

A textarea where typing @ opens a people menu and inserts a highlighted mention chip.

This is a WebberUI Pro component

Free during the launch campaign: sign up or sign in, then hit “Copy install command” in the preview above and it installs straight away — no payment, no credit card. The command below returns 401 while you are signed out.

How to install Pro components →See the plans →

Typing @ instantly opens a keyboard-operable floating member menu; picking someone inserts a colour-highlighted @name chip, and onChange reports every member currently mentioned in the text — a good fit for comments, replies, and collaboration tools.

Loading preview…
npx shadcn@latest add "https://webberui.com/r/mention-textarea.json?t=<install token>"

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

4
6
<MentionTextarea />

Installation

npx shadcn@latest add "https://webberui.com/r/mention-textarea.json?t=<install token>"

Or, once registries are configured in components.json, install it as @webberui/mention-textarea.

Usage

import {
  MentionTextarea,
  type MentionUser,
} from "@/components/ui/mention-textarea";

const users: MentionUser[] = [
  { id: "u1", name: "Lin Xiaomei", hue: 340, title: "Product Designer" },
  { id: "u2", name: "Chen Dawen", hue: 210, title: "Frontend Engineer" },
];

<MentionTextarea
  users={users}
  placeholder="Type a message, use @ to mention someone…"
  onChange={(value, mentions) => console.log(value, mentions)}
/>

Props

PropTypeDefaultDescription
usersMentionUser[]The list of mentionable members ({ id, name, hue, title? }), used to filter the menu when @ is typed
valuestringText value in controlled mode, used together with onChange
defaultValuestring""Initial text value in uncontrolled mode
onChange(value: string, mentions: MentionUser[]) => voidCallback for content changes; the second argument is every member currently mentioned in the text
placeholderstring"輸入訊息,使用 @ 提及成員…"Placeholder hint text of the input
rowsnumber4Number of rows the textarea shows
maxMenuItemsnumber6Maximum number of members the menu shows at once
classNamestringForwarded to the outermost container and merged with cn()

Accessibility

  • The input is marked role="combobox", aria-expanded, aria-autocomplete="list", the menu is role="listbox", and items are role="option" with aria-activedescendant pointing at the current option
  • Full keyboard support: / move between options, Enter or Tab inserts, Escape closes the menu
  • Menu items intercept the click with onMouseDown, so focus stays in the input throughout the selection
  • When the user has "reduce motion" enabled at the system level, the menu becomes a plain fade in / fade out and the spring displacement of the selection block is turned off
  • The highlight layer is an aria-hidden purely visual mirror; assistive technology still reads the textarea's original plain text content

On this page