Skip to content
nexubDesign System
v12.7.0

Components · Form Controls

Autocomplete

StableAdded v0.0.1 · updated v5.2.0

Type-to-search input with matching options dropdown.

import { Autocomplete } from '@nexub/react';
View as Markdown

Playground

Props

size
TSX
<Autocomplete options={…} placeholder="Search framework…" />

Examples

Default

With loading state

Custom empty text

Fetch as you type

`onInputChange`: the app filters, the list shows skeleton rows while loading.

Add mode with a label

Reviewers: —

States

  • default
  • disabled
  • readOnly
  • loading
  • size="sm"
  • size="md"
  • size="lg"

Props

Props
PropTypeDefaultDescription
optionsrequiredAutocompleteOption[]—Array of options available for selection.
valuestring—The controlled selected value.
onValueChange((value: string) => void)—Callback fired when the selected value changes.
placeholderstring—Placeholder text shown in the input when empty.
emptyTextstring—Text shown when no options match the current search query.
loadingbooleanfalseSkeleton rows while options are being fetched (5.2); "Loading" is announced.
inputValuestring—Controlled input text (5.1).
onInputChange((text: string) => void)—Called as the user types, so you can fetch options (5.1). When set, options are shown as given, without built-in filtering.
onCreate((text: string) => void)—Adds a "Create “text”" option when the text matches no option (5.2).
aria-labelstring—Accessible name of the field when it has no visible label.
labelReact.ReactNode—11.2: a visible label above the field.
clearOnSelectboolean—11.2: "add" mode: the text empties after a pick.
onClear(() => void)—11.2: called from the clear button or when the text is deleted; shows the clear button.
options[].description / disabledstring / boolean—11.2: a second line (also searched), and options that can't be picked.
classNamestring—
disabledboolean—
idstring—11.2: the input's id (the label points at it).
readOnlyboolean—Shows the value but it can't be changed; stays focusable.
sheetfalse | true | 'auto''auto' (pass `sheet={false}` to keep a popover on small screens)true: bottom sheet. 'auto': bottom sheet below the md breakpoint, a popover above.
size'sm' | 'md' | 'lg''md'

On iOS & Android