Skip to content

Suggestion List

Last updated 6 Nov 2026

NbSuggestionList is the autocomplete list under a text field: people for an @mention, items for a reference, tags for a tag field. It goes in NbTextInput's #dropdown slot.

The product decides when it opens and what it offers, because that is the product's business: which character starts a mention, how names match. The list does the part every product would otherwise write by hand:

  • ↓ and ↑ move the active suggestion, wrapping at both ends.
  • Enter or Tab chooses it, a click chooses any row.
  • Esc closes the list, and only the list: not the modal the field sits in.
  • Leaving the field closes it.
  • Focus never leaves the field. The field becomes a combobox that points at the active row with aria-activedescendant, so a screen reader hears each suggestion while the caret stays put.

Try it ​

Type @ and the start of a name.

Rows ​

The item slot draws a row. It receives the item, its index, and whether it is active. Without it, a row is the item's label: item-label if given, otherwise item.label, otherwise the item itself, so a plain list of strings needs nothing else.

Empty ​

With empty-text (or an #empty slot), a list with no matches says so. Without either, an empty list is not drawn at all, which suits a list that only opens on a match.

Above the field ​

placement="top" opens the list above the field, for a composer at the bottom of a panel where a list below would fall off the screen.

A handler on the same field ​

The list listens before anything else on the field, so a key it uses is already marked handled when your own @keydown sees it. A composer that sends on Enter checks event.defaultPrevented to tell a chosen suggestion from a send.