Skip to Content
MavKitOne is in beta. @mav-labs-inc/mavkit-react is not public packages yet.
ComponentsAuto Complete

Auto Complete

A type-to-filter combobox. Focus stays on the input; typing filters options by label without changing the committed value — a selection only commits when an option is clicked or Enter is pressed on the highlighted option.

Usage

import { AutoComplete } from '@mav-labs-inc/mavkit-react' <AutoComplete label="Country" options={[{ value: 'us', label: 'United States' }, { value: 'ca', label: 'Canada' }]} onSelectionChange={onChange} />

Examples

Basic

  • United States
  • Canada
  • Mexico
  • United Kingdom
  • Germany
  • France
  • Japan

With a default value and validation

  • United States
  • United States
  • Canada
  • Mexico
  • United Kingdom
  • Germany
  • France
  • Japan

Props

PropTypeDefaultDescription
options*AutoCompleteOption[]—{ value: string; label: string; disabled?: boolean }[]
valuestring | null—Controlled selected value — pair with onSelectionChange.
defaultValuestring | null—
onSelectionChange(change: { value: string; label: string } | null) => void—Fires when a selection commits (option clicked/Enter) or is cleared (null).
onQueryChange(query: string) => void—Fires on every keystroke with the current query text — for async/server-side filtering.
filter(option: AutoCompleteOption, query: string) => boolean—Custom match predicate. Default: case-insensitive substring match on label.
placeholderstring—
labelReactNode—Field label. Omitting it renders an unlabelled control — pass ariaLabel yourself in that case.
requiredboolean—
helperTextReactNode—Superseded by errorText/successText while either is set.
errorTextReactNode—Sets .is-error, aria-invalid, and a role="alert" message.
successTextReactNode—Sets .is-success. Ignored while errorText is set.
noOptionsTextReactNode'No results found'Shown in the panel when the filter yields no matches.
namestring—Renders a hidden input for plain-form submission.
ariaLabelstring—
classNamestring—className for the outer .autocomplete-group.
clearablebooleantrueShows a clear button once there's query text.
disabledboolean—
idstring—
refRef<AutoCompleteHandle>—{ open(), close(), clear(), setValue(value) }
Last updated on