Command palette

@yasinsensoy/native

React Native · Components

Autocomplete

Text box that filters suggestions as you type.

4 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Code

import { Label, Autocomplete } from "@yasinsensoy/native";

<Label htmlFor="search">Ara</Label>
<Autocomplete id="search" name="search" placeholder="Start typing…" icon="search"
  items={iller}
  onValueChange={(value) => …} />

Events

  1. Events appear here when you interact with the preview.

AutocompleteField: tag input and required field

react

Pick from the list or type and press Enter.

Import

import { Autocomplete } from "@yasinsensoy/native";

Autocomplete

component

Text box that filters suggestions as you type. Uses the same options, list and loading modes as Select.

  • Since the keyboard stays open, suggestions open right below the box in the page flow (not a bottom sheet); rows are thumb-sized.
  • With allowCustomValue text not in the list also becomes a value; the keyboard's "Done/Enter" adds it.
  • With multiple selected items become tags in the box; removed with ✕.
Autocomplete(props: AutocompleteProps): ReactElement<unknown, string | JSXElementConstructor<any>>

Examples

<Autocomplete label="City" placeholder="Search cities" items={cities} />
<Autocomplete multiple allowCustomValue label="Tags" items={["react", "expo"]} />

Single selection.

Extends: FieldProps

NameTypeDefaultDescription
multiple?falseSingle selection.
value?stringSelected value (controlled).
defaultValue?stringInitial value.
onValueChange?(value: string, item: SelectItem | undefined) => voidWhen the selection changes.
items?SelectItemsSourceSuggestions: an array, a Promise or a function called once.
loadItems?SelectLoaderFunction that searches and paginates on the server.
allowCustomValue?booleanfalseText not in the list also becomes a value (tags, email recipients).
openOnFocus?booleanfalseShould the list open on focus (without typing)?
inputValue?stringText in the box, for controlled use.
onInputChange?(text: string) => voidWhen the text in the box changes.
placeholder?stringPlaceholder.
emptyMessage?ReactNodeWhen there are no suggestions.
icon?IconPropIcon at the start of the box.
clearable?booleantrueClear button.
open?booleanWhether the list is open, for controlled use.
onOpenChange?(open: boolean) => voidWhen the list opens or closes.
variant?FieldVariant"outline"Field variant.
aria-label?stringScreen reader name; give it if there is no visible label.
style?StyleProp<ViewStyle>Container style.

Multiple selection: selected items become tags in the box.

Extends: FieldProps

NameTypeDefaultDescription
multipletrueMultiple selection.
value?readonly string[]Selected values (controlled).
defaultValue?readonly string[]Initial values.
onValueChange?(value: string[], items: SelectItem[]) => voidWhen the selection changes.
items?SelectItemsSourceSuggestions: an array, a Promise or a function called once.
loadItems?SelectLoaderFunction that searches and paginates on the server.
allowCustomValue?booleanfalseText not in the list also becomes a value (tags, email recipients).
openOnFocus?booleanfalseShould the list open on focus (without typing)?
inputValue?stringText in the box, for controlled use.
onInputChange?(text: string) => voidWhen the text in the box changes.
placeholder?stringPlaceholder.
emptyMessage?ReactNodeWhen there are no suggestions.
icon?IconPropIcon at the start of the box.
clearable?booleantrueClear button.
open?booleanWhether the list is open, for controlled use.
onOpenChange?(open: boolean) => voidWhen the list opens or closes.
variant?FieldVariant"outline"Field variant.
aria-label?stringScreen reader name; give it if there is no visible label.
style?StyleProp<ViewStyle>Container style.

Props of Autocomplete (same names as web).

type AutocompleteProps = SingleAutocompleteProps | MultiAutocompleteProps

Extends: FieldProps

NameTypeDefaultDescription
multiple?false | trueSingle selection.
value?string | readonly string[]Selected value (controlled).
defaultValue?string | readonly string[]Initial value.
onValueChange?(value: string, item: SelectItem | undefined) => void | (value: string[], items: SelectItem[]) => voidWhen the selection changes.
items?SelectItemsSourceSuggestions: an array, a Promise or a function called once.
loadItems?SelectLoaderFunction that searches and paginates on the server.
allowCustomValue?booleanfalseText not in the list also becomes a value (tags, email recipients).
openOnFocus?booleanfalseShould the list open on focus (without typing)?
inputValue?stringText in the box, for controlled use.
onInputChange?(text: string) => voidWhen the text in the box changes.
placeholder?stringPlaceholder.
emptyMessage?ReactNodeWhen there are no suggestions.
icon?IconPropIcon at the start of the box.
clearable?booleantrueClear button.
open?booleanWhether the list is open, for controlled use.
onOpenChange?(open: boolean) => voidWhen the list opens or closes.
variant?FieldVariant"outline"Field variant.
aria-label?stringScreen reader name; give it if there is no visible label.
style?StyleProp<ViewStyle>Container style.