You are viewing a PR preview for PR #1506

Agriculture Design System
Beta
Design System for the Export Service

Autocomplete

Autocomplete, also known as type-ahead, uses predictive text to complete words as they are entered.

View in FigmaView in StorybookView in Github
import { ... } from '@ag.ds-next/react/autocomplete';

Usage

Autocomplete components can be imported via the autocomplete entrypoint in the @ag.ds-next/react package.

For example:

import { ... } from '@ag.ds-next/react/autocomplete';

Props

Autocomplete Props
PropTypeDescription
labelstringDescribes the purpose of the field.
loadOptions(inputValue: string) => Promise<Option[]>Function to be used when options need to be loaded over the network.
block?booleanIf true, the field will stretch to the fill the width of its container.
disabled?booleanIf true, the field will not be interactive.
emptyResultsMessage?stringDefault: "No results found"Message to display when no options match the users search term.
hideOptionalLabel?booleanIf true, "(optional)" will never be appended to the label.
hint?stringProvides extra information about the field.
id?stringDefines an identifier (ID) which must be unique.
inputRef?RefObject<HTMLInputElement>Ref to the input element.
invalid?booleanIf true, the invalid state will be rendered.
maxWidth?"md" | "lg" | "xl"The maximum width of the field.
message?stringMessage to show when the field is invalid.
name?stringA string specifying a name for the input control.
onBlur?FocusEventHandler<HTMLInputElement>Function to be fired following a blur event.
onChange?((value: Option | null) => void)Function to be fired following a change event.
onFocus?FocusEventHandler<HTMLInputElement>Function to be fired following a focus event.
openDropdownOnFocus?boolean@deprecated This prop is no longer being used. When true, the dropdown will open when the user focuses on the element
renderItem?((item: Option, inputValue: string) => ReactNode)Used to override the default item rendering.
required?booleanIf false, "(optional)" will be appended to the label.
value?DefaultComboboxOption | nullThe value of the field.

AutocompleteRenderItem Props

AutocompleteRenderItem does not have any props.

Source

You can view the full source code for this package on Github.