Props

Name
Type
Default
accessibilityLabel
Required
string
-

String that clients such as VoiceOver will read to describe the element. Always localize the label. See the Accessibility section for more info.

id
Required
string
-
onChange
Required
({ value: string, syntheticEvent: SyntheticEvent<HTMLInputElement> }) => void
-
accessibilityClearButtonLabel
string
-

String that clients such as VoiceOver will read to describe the clear button element. Always localize the label. See the Accessibility section for more info.

autoComplete
"on" | "off" | "username" | "name"
-
errorMessage
string
-
label
string
-

Text used to label this search field. Should be localized. See the Visible label variant for more info.

onBlur
({ event: SyntheticEvent<HTMLInputElement> }) => void
-
onFocus
({ value: string, syntheticEvent: SyntheticEvent<HTMLInputElement> }) => void
-
onKeyDown
({ event: SyntheticKeyboardEvent<HTMLInputElement>, value: string }) => void
-

Callback for key stroke events.

placeholder
string
-
ref
React.Ref<"input">
-

Forward the ref to the underlying input element

size
"md" | "lg"
"md"

md: 40px, lg: 48px

value
string
-

Accessibility

Labels

SearchField should ideally have a visible label above the input using the label prop. However, if need be, accessibilityLabel can be used to provide screen readers with context about this SearchField.

Be sure to also specify (and localize) a string for the accessibilityClearButtonLabel.

Variants

Visible label

When specified, label adds a label above the SearchField. If label is specified, accessibilityLabel can be an empty string.

Sizes

There are 2 sizes available: md (default) and lg.

Medium (md)
Large (lg)

Error

An errorMessage can be specified if needed.

Invalid search term, please avoid special characters.