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';Playground
Props
size
<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
States
defaultdisabledreadOnlyloadingsize="sm"size="md"size="lg"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| optionsrequired | AutocompleteOption[] | — | Array of options available for selection. |
| value | string | — | The controlled selected value. |
| onValueChange | ((value: string) => void) | — | Callback fired when the selected value changes. |
| placeholder | string | — | Placeholder text shown in the input when empty. |
| emptyText | string | — | Text shown when no options match the current search query. |
| loading | boolean | false | Skeleton rows while options are being fetched (5.2); "Loading" is announced. |
| inputValue | string | — | 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-label | string | — | Accessible name of the field when it has no visible label. |
| label | React.ReactNode | — | 11.2: a visible label above the field. |
| clearOnSelect | boolean | — | 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 / disabled | string / boolean | — | 11.2: a second line (also searched), and options that can't be picked. |
| className | string | — | |
| disabled | boolean | — | |
| id | string | — | 11.2: the input's id (the label points at it). |
| readOnly | boolean | — | Shows the value but it can't be changed; stays focusable. |
| sheet | false | 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
Web only
Autocomplete has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.