Typeahead
Deprecated

Use the new Combobox instead

Props

Name
Type
Default
Required
string
-
Required
string
-

The text shown when the input value returns no matches

Required
Array<{ label: string, value: string, subtext: string }>
-

The data must be an array with objects containing only label and value properties

label
string
-
({ event: SyntheticFocusEvent<HTMLInputElement> | SyntheticEvent<HTMLInputElement> , value: string }) => void
-

Callback when you focus outside the component

({ event: SyntheticInputEvent<>, value: string }) => void
-

Callback when user types into the control input field

({ event: SyntheticFocusEvent<>, value: string }) => void
-

Callback when you focus on the component

({ event: SyntheticKeyboardEvent<HTMLTextAreaElement>, value: string }) => void
-

Callback for key stroke events. This callback is useful for tag management.

({ event: SyntheticInputEvent<>, value: string }) => void
-

Callback when you select an item

string
-
React.Ref<"input">
-

Forward the ref to the underlying component container element

size
"md" | "lg"
"md"

md: 40px, lg: 48px

Array<Element<typeof Tag>>
-

List of tags to display in the component

string
-

The default value set in the Typeahead

interface Indexable { index(): number; }
-

An object representing the z-index value of the Typeahead list. Only use when Typeahead is used within a parent component that has a z-index set.

Example

Selected Item:

Default Item Example

Selected Item: Label-4

With Subtext

Selected Item:

With Ref

With Tags

You can include Tag elements in the input using the tags prop.

Note that the Typeahead component does not internally manage tags. That should be handled in the application state through the component's event callbacks. We recommend creating new tags on enter key presses, and removing them on backspaces when the cursor is in the beginning of the field. We also recommend filtering out empty tags.

This example showcases the recommended behavior.

With ZIndex

When Typeahead is used within a parent component that has a z-index set, a z-index will also need to be set on the Typeahead. Otherwise the Typeahead will render behind the parent component in the stacking context. Visit our Z-Index documentation for more details on how to use these utility classes.