Search field
A search field is used for searching and filtering items.

Anatomy#

Options#
Table of options#
From the design point of view, each component has a number of options. These options and their names are platform agnostic, and each implementation should adapt these to fit into their framework.
Behaviors#

Minimum width#
The minimum width for a search field is 3× the height of the field, for both standard and quiet style. This minimum width guarantees that small search fields are readable and easy to target on touch devices.

Text overflow#
When the entered text is too long for the available horizontal space in the field, the text truncates.

Help text overflow#
When the help text is too long for the available horizontal space, it wraps to form another line.

Keyboard focus#
A search field can be navigated using a keyboard. The keyboard focus state takes the field’s visual hover state and adds a blue ring to the field in focus.

In-field button#
The in-field button offers an option to clear any input search term.
If search results are being shown in a menu or popover, selecting this button will close the menu and clear the field. If a search term has been entered and the results have appeared, selecting this will only clear the field and not affect the list of results.

Windows high contrast mode#
In Windows high contrast mode, a search field should be displayed using the high contrast theme-specified colors for buttons. By default, the border color should be the same as the button text color and labels should use default text color. In hover and keyboard focus states, the border color should display as the button border color. In the disabled state, border and text color should display as the disabled color.
Usage guidelines#
Show a "No results" state instead of an error#
Search fields do not have an error state. Search functionality should anticipate spelling mistakes in search queries, and accommodate multiple spellings of words in search results —
Instead of showing an error, show a “No results” page or a section with any suggestions for how to get results to appear.




Searching vs. filtering#
In a searching scenario, a user inputs a search term for a specific thing they’re looking for. In a filtering scenario, a user generally knows what they’re looking for, but may not have a specific thing in mind.
The search field can be used for both of these contexts. For a search experience, use the search field as-is. For a filtering experience, add a filter icon next to the search field, where a user can narrow down their search results before (or instead of) searching using a specific term. Filters can appear below the search field as tags.


Searching within a category#
Create a scoped search by pairing a search field with a
Spectrum previously had a specific “search within” component that would allow a user to filter down a search field category before searching for a particular term. It was deprecated because it did not meet accessibility and localization requirements.


Include a label#
Any search field should include a label inside the field, in the default state. The default label text is Search, but this can be customized to be more specific for use cases like scoped search, wayfinding, or building context — acting like a prompt for a user to search more specifically (e.g., Search templates).
Keep in mind that once a search term is entered the label text is no longer viewable. Use help text to show search formatting examples or give hints about what to input. It can be distracting or redundant if the search field label and its help text are both communicating the same thing, so write these thoughtfully.




Follow capitalization rules#
The label within the search field should be in sentence case, following




Internationalization#
Keyboard interactions#
Changelog#
- This component was added to the website.
- Added additional options, behaviors, usage guidelines, internationalization guidelines, keyboard interactions, and theming.
- Icon changed from UI icon to workflow icon.
- Updated colors to 6.0.0.
- Changed placeholder text to function as a label in body text style.
Design checklist#

All interactive states
Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).

All color themes
Works properly across all four color themes (lightest, light, dark, darkest).

All platform scales
Includes a desktop scale (UWP, macOS, web desktop) and a mobile scale (iOS, Android, web mobile).

Accessible use of color
Color is not used as the only visual means of conveying information (WCAG 2.0 1.4.1).

Accessible contrast for text
Text has a contrast ratio of at least 4.5:1 for small text and at least 3:1 for large text (WCAG 2.0 1.4.3).

Accessible contrast for UI components
Visual information required to identify components and states (except inactive components) has a contrast ratio of at least 3:1 (WCAG 2.1 1.4.11).

Content design
UI language and information design considerations have been incorporated into component design.

Defined options
Includes relevant options (variant, style, size, orientation, optional iconography, decorations, selection, error state, etc.)

Defined behaviors
Includes guidelines for keyboard focus, layout (wrapping, truncation, overflow), animation, interactions, etc.

Usage guidelines
Includes a list of dos and don'ts that highlight best practices and common mistakes.

Writing guidelines
Includes content standards or usage guidelines for how to write or format in-product content for the component.

Internationalization guidelines
Works properly across various locales and includes guidelines for bi-directionality (RTL).

Keyboard interactions
Follows WCAG 2.0 standards for keyboard accessibility guidelines and includes a description of the keyboard interactions.
Design tokens
All design attributes (color, typography, layout, animation, etc.) are available as design tokens.

UI kit
Includes a downloadable XD file that shows multiple options, states, color themes, and platform scales.

Generated UI kit
Includes a downloadable XD file, generated by code using design tokens defined in Spectrum DNA, and shows multiple options, states, color themes, and platform scales.

In Spectrum for Adobe XD plugin
Component is included in the Spectrum for Adobe XD plugin.