Ballmac UI home

Mention Input

A text field where typing @ or # opens a list of people, channels or tags: highlighted mentions that know their id, async search, arrow-key choosing, whole-mention backspace and a combobox pattern for screen readers.

Installation

$ pnpm dlx shadcn@latest add @ballmac/mention-input

Usage

import { MentionInput } from "@/components/ballmac/mention-input"

The full example is in the Code tab above.

Examples

Search as you type

Single line with tags

Press Enter to send. Tags are kept with the ticket.

Invalid and disabled choices

Jonas is away and cannot be chosen.

API reference

PropTypeDefault
value

The text and its mentions, when you hold them in state. Pair with `onValueChange`.

MentionValue—
defaultValueMentionValue—
onValueChange(value: MentionValue) => void—
sources*MentionSource[]—
minRows

Rows to show at first. The field grows with its text up to `maxRows`.

number3
maxRowsnumber8
singleLine

One line, like a search box: Enter does not add a line.

booleanfalse
invalidbooleanfalse
onSubmit

Called when Enter is pressed with no list open, in a single-line field or with Ctrl or Cmd held.

(value: MentionValue) => void—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Type @ or #Opens the list under the caret; the field is a combobox with aria-activedescendant
Arrow Up / Arrow DownChoose a suggestion; disabled ones are skipped
Enter / TabInsert the highlighted suggestion
EscapeClose the list without inserting
Backspace after a mentionRemoves the whole mention
Screen readersThe count of suggestions and the highlighted one are announced; Searching and No matches are announced too

Quality scorecard

7/7

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 4 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    No endless animation to begin with.

  • Passed: Right to left

    Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Passed: Keyboard

    4 tab stops, each showing a visible change when it takes focus. 6 documented keys.

  • Not applicable: Loading, empty and error

    Nothing loads on its own: an async source shows a Searching row in the list while it answers, and a No matches row when it finds nothing.

  • Passed: Automated tests

    Covered by mention-input.test.tsx.

  • For information: Footprint

    6.1 KB of source (gzip) in 1 file. Installs lucide-react.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Use with AI

Hold { text, mentions } in state: <MentionInput value onValueChange sources={[{ trigger: "@", options }]} />. options is an array or a function (query, signal) returning options or a promise. mentionsToMarkup and parseMentionMarkup convert to a string. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Mention Input (@ballmac/mention-input) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Comments, chat and ticket replies where people are mentioned
  • Tag or channel pickers inside a sentence
  • Anywhere you need to know which entity a name in the text referred to

Not for

  • Formatting text as well as mentions; use rich-text-editor
  • Choosing one value from a list; use combobox
  • Plain multi-line text; use textarea

Registry JSON: https://ui.ballmac.com/r/mention-input.json

Credits

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.