Props
Best practices
Place SearchField above the content the user will be searching.
Hide SearchField behind an IconButton if there is enough space for the full component.
Make the placeholder
specific. Give the user a hint about the content they're searching and/or what parameters they can use to search.
Add critical information to the placeholder
. The placeholder
text disappears once the user begins entering data and will therefore be unavailable.
Make sure SearchField is displayed wide enough to completely display common search terms.
Truncate or wrap text within SearchField.
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 the SearchField.
Be sure to also specify (and localize) a string for the accessibilityClearButtonLabel
.
Localization
Be sure to localize the accessibilityLabel
, accessibilityClearButtonLabel
, errorMessage
, label
and placeholder
prop values. Also localize value
for those cases when it can be translated.
Note that localization can lengthen text by 20 to 30 percent.
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
.
Error
An errorMessage
can be specified if needed.
Component quality checklist
Quality item | Status | Status description |
---|---|---|
Figma Library | Ready | Component is available in Figma across all platforms. |
Responsive Web | Ready | Component is available in code for web and mobile web. |
iOS | Component is not currently available in code for iOS. | |
Android | Component is not currently available in code for Android. |
Related
ComboBox
ComboBox allows users to filter a list when selecting an option. Choose ComboBox when the user is selecting from a finite list of options.
TextField
TextField provides an affordance to input small to medium length text. Unless the text is used to search for or filter through content, choose TextField for shorter text input.
TextArea
TextArea allows for multiline text input, suitable for longer length text. Unless the text is used to search for or filter through content, choose TextArea for longer text input.