Homecomponentsinput

Alpha
This component is in development. There could be breaking changes made to it in a non-major release of Prism. Please use with caution.

Overview

Create a text input that aids in filtering and selecting from a list of options. It also supports all features of the TextField.

Here's an example of a simple Autocomplete.

Required Selection

Use the required property require a selection.

Here's an example of a required Autocomplete.

Empty State

Use emptyState property to show when there are no options available.

Highlight search matches

Use highlightMatches property to highlight found matches in Autocomplete dropdown.

Show a Loading Indicator

Use the loading property to show a loading indicator.

API

onQueryChange
Required
Called when the query is changed.
(value: string) => void

onChange
Required
Called when a selection is made.
(value: string | null) => void

options
Required
The options to display.
AutocompleteOption[]

emptyState
Required
The text or element to show when no matches found.
string

name
Required
Name for the field.
string

query
The query.
string

value
The id of the option.
string | null

loading
Show a loading indicator.
true
false

highlightMatches
Highlights the matches if true.
true
false

id
ID of the field.
string

prefix
Content to display before the field.
ReactNode

onBlur
Action to perform when the field is blurred.
FocusEventHandler<HTMLInputElement>

onKeyDown
Action to perform when a key is pressed.
KeyboardEventHandler<HTMLInputElement>

size
Size of the field.
small
regular

textAlign
Aligns the text horizontally.
center
end
start

disabled
Disables the field.
true
false

data
An object with the data keys and values.
DataAttributeMap

label
Adds a label to the field.
string

placeholder
Placeholder of the text field.
string

required
Indicates the field is required.
true
false

suffix
Content to display after the field.
ReactNode

maxLength
Maximum character length for an field.
number

tip
Tooltip shown next to the label.
string

secondaryLabel
Adds a secondary label to the field.
ReactNode

description
Note shown below the field.
string

errorMessage
Displays an error message under the field.
string

ref
Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
Ref<HTMLInputElement>

key
Key | null