Skip to content
English
Mention input comes with Pro. Its preview shows once you unlock it.

How it works

There is no contenteditable. The textarea draws only the caret and selection; a mirror with the same box model sits behind it and draws the text, with each mention as an accent token. A hidden second mirror measures the caret so the list opens under the @, clamped inside the field. Text stays a plain string, easy to store and diff.

Use it for

  • Comments, replies and notes where people notify teammates by name.
  • Any message field that must keep native mobile keyboards, autocorrect and IME.

Look elsewhere when

  • Rich formatting (bold, links, images): use a rich-text editor.
  • Picking recipients only, without free text: use a tags input or multi-select.

Usage

import { useState } from 'react'
import { MentionInput } from './MentionInput.jsx'

const people = [
  { id: 'm', name: 'Mira Holt', role: 'Design lead' },
  { id: 'j', name: 'Jonas Reed', role: 'Illustrator' },
]

export function Reply() {
  const [text, setText] = useState('')
  return (
    <MentionInput
      aria-label="Reply"
      value={text}
      onChange={(next, mentioned) => setText(next)}
      people={people}
      placeholder="Type @ to mention someone"
    />
  )
}

Props

PropTypeDefaultWhat it does
people{ id?, name, role?, handle?, color? }[]—Who can be mentioned. A word of name or the handle is matched from its start.
valuestring—Controlled text. Mentions are stored as plain "@Name".
defaultValuestring''Initial text when uncontrolled.
onChange(text, mentioned: Person[]) => void—Called on every edit with the text and the people currently mentioned in it.
triggerstring'@'Character that starts a mention; it must follow a space or the start.
rowsnumber3Visible rows of the textarea.
maxLengthnumber—Character limit; shows a counter that turns amber past 90%.
renderPerson(person) => ReactNode—Replaces the default initial avatar in the list.
labelsobject—Replaces built-in text: people, noMatch, mentioned.
...restTextareaHTMLAttributes—Go to the textarea, including onKeyDown (called after list navigation) and aria-label. List layer: --ds-mention-z (30).

Accessibility

  • The textarea is a combobox (aria-autocomplete="list", aria-multiline) controlling a listbox; the highlighted person is announced through aria-activedescendant.
  • Keyboard: Down / Up move through people, Enter or Tab insert, Esc closes the list and keeps the text; Backspace after a token removes the whole name.
  • Each inserted mention is announced in a polite live region. The visible text is the real text, so screen readers read "@Name" naturally.
  • People rows are 44px. Reduced motion removes the list and token glow animations.

Motion

The list scales in from 0.96 and 4px above in 200ms ease-out. A new token starts with a stronger tint and a 4px glow that settle over 360ms. The field turns white with a halo in 220ms.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

MentionInput.jsxmention-input.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Form inputs
Availability grid comes with Pro. Its preview shows once you unlock it.
Boolean operations comes with Pro. Its preview shows once you unlock it.
Cascader comes with Pro. Its preview shows once you unlock it.