Skip to content

Mention Input for Angular

AngularInputs

A plain-text field that suggests people, tags, or other entities when the user types a trigger character such as @ or #. Suggestions come from an async provider (debounced, aborted when superseded); inserted mentions are kept as structured tokens { id, label, trigger, start, end } whose offsets follow every edit. Nothing is rendered as HTML. A Form control with a hidden input carrying the JSON value.

  • Structured mentionsThe value keeps each mention as { id, label, start, end }, and the offsets follow every edit.
  • Async and abortableDebounced provider calls with an AbortSignal per query; stale answers are never shown.
  • Several triggers@ for people, # for tags, or any character with its own provider.
  • Plain text onlyNo HTML or contenteditable: the text is stored and rendered as text.
  • AnnouncedResult counts, no matches, and inserted mentions are announced to screen readers.

Behavior, design tokens, and limitations are described on the Mention Input page; this page covers the Angular API.

import { Component } from '@angular/core';
import type { MentionInputValue, MentionTrigger } from '@absoluteui/components/mention-input';
import { AuiMentionInput } from '@absoluteui/angular/mention-input';
@Component({
selector: 'app-comment',
imports: [AuiMentionInput],
template: `<aui-mention-input label="Comment" [triggers]="triggers" [(value)]="comment"></aui-mention-input>`,
})
export class CommentComponent {
comment: MentionInputValue = { text: '', mentions: [] };
readonly triggers: MentionTrigger[] = [{ char: '@', label: '@ for people', provider: (query) => Promise.resolve([{ id: 'u1', label: 'Ana' }].filter((p) => p.label.startsWith(query))) }];
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiMentionInput } from '@absoluteui/angular/mention-input';

Defaults for every instance: provideAbsoluteUIConfig({ components: { mentionInput: { ... } } }) (see Configuration).

Class AuiMentionInput; template reference #ref="auiMentionInput".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Angular forms: implements ControlValueAccessor and Validator; the form value is MentionInputValue. Bind [formControl], formControlName, or [(ngModel)]; validation messages of the component report through the aui error key. See Forms.

Input Type Default Description
label string Required. Visible label and accessible name.
hideLabel boolean false Visually hide the label; it remains the accessible name.
description string Help text referenced by aria-describedby.
placeholder string Supplementary hint; never replaces the label.
triggers readonly MentionTrigger[] Required. Trigger characters with their async providers: { char, provider(query, { signal, trigger }), label?, minChars? }.
name string Form field name; the hidden input carries the JSON value.
required boolean false Empty text is invalid; shows the required indicator.
disabled boolean false Disables the field.
readOnly boolean false Focusable and submitted, not editable; no suggestions.
multiline boolean true true: a textarea; false: a single-line input with the combobox role.
rows number '3' Visible rows of the textarea.
maxLength number Maximum length in code points (validated, not truncated).
showCounter boolean false Show remaining/over characters; requires maxLength.
validate (value: MentionInputValue) => string | null Consumer validation; return a message to mark the value invalid.
icons Partial<MentionInputIcons> Icon slot overrides.
validationTiming ValidationTiming 'blur' When validation messages first appear; afterwards they update live.
debounce number '200' Milliseconds between the last keystroke and the provider call (0 to 5000).
maxSuggestions number '8' Most suggestions shown at once (1 to 50).
locale string 'en-US' Message and number-formatting locale.
Model Type Change output Description
[(value)] MentionInputValue (valueChange) The value: [(value)] without forms; with Angular forms, bind the form control instead.
Output Payload Description
(valueInput) MentionInputValueDetail The text or mentions changed: { value, validity }. Re-emits aui-input.
(changed) MentionInputValueDetail Committed: a mention was inserted, or focus left with a changed value. Re-emits aui-change.
(mentioned) MentionInputMentionDetail A suggestion was inserted: { mention }. Re-emits aui-mention.

Call them through a viewChild query or a template reference.

Method Description
reportValidity(): boolean | undefined Show messages now and return validity.
setCustomError(message: string | null): void External error; cleared when the user edits.
getFormValue(): MentionInputValue | undefined Value for form serialization.
focus(): void Focus the field.
reset(): void Restore the initial value and clear dirty/touched/submitted state.

Pattern: WAI-ARIA APG Combobox with a listbox popup (list autocomplete). The single-line field is role=combobox with aria-expanded; the textarea keeps its native textbox role (ARIA does not allow combobox on textarea) and exposes aria-autocomplete, aria-controls, and aria-activedescendant.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Mention Input: Accessibility and performance.