Skip to content
SENVENLI UI

Autocomplete

Free text with suggestions loaded as people type, grouped and with detail lines.
Free text with suggestions
import { Autocomplete } from "@senvenli/react/selection";

Examples

Grouped, with icons

Suggestions under headers, in the order the groups prop gives.

Required

Left empty, the field reports itself on blur.

Guidelines

When to use it

  • Free text where suggestions help: addresses, places.

Use something else when

  • The value must be one of a known list. Combo box

Accessibility

Built in

  • Announces loading and the suggestion count.
  • Required fields show "Fill in this field." after a blur or a submit; your own errorMessage replaces it.

You provide

  • A visible label.

API reference

Autocomplete

labelRequired
React.ReactNode
valueRequired
string

The free text; it is a valid value on its own.

onChangeRequired
(value: string) => void
getSuggestionsRequired
(text: string, signal: AbortSignal) => Promise<AutocompleteSuggestion[]>

Suggestions for the typed text (called after minLength characters, debounced).

onSelectSuggestion
(suggestion: AutocompleteSuggestion) => void

Called when a suggestion fills the text, with the suggestion itself (coordinates, ids).

groups
readonly string[]

Group order ("Suggested places" first, then "Addresses").

icon
IconName

The field's context icon (default search).

description
React.ReactNode
errorMessage
React.ReactNode
placeholder
string
isRequired
boolean
requiredValidation
RequiredValidation

Who says an empty required Autocomplete is missing: field (default) shows "Fill in this field." on blur and on a DS Form submit, which it then blocks; app only marks the field. See {@link RequiredValidation}. The app's isInvalid (true with its errorMessage, or false) overrides the check, as on TextField. Disabled, empty and required, it still blocks a DS Form's submit and cannot take focus (as TextField).

isDisabled
boolean
isInvalid
boolean
name
string
minLength
number

Characters before suggesting (default 2).

debounce
number

Debounce in ms (default 250).

size
FieldSize
radius
ComponentRadius

Corner radius: none, small, medium (the design), large or full. The provider's default otherwise.