Search field

v2.0

The search field filters a list using custom characters and keywords.

Anatomy

Two search fields showing icons, placeholder text, and layout variants.
  1. Search icon
  2. Placeholder text
  3. Field container
  4. Trailing accessory
  5. Input text
  6. Clear button

Options

Size

Search fields are available in small, medium, and large sizes. The default size is small and the tap target is 48px across all sizes.

Three search bars at 48px, 40px, and 32px height with same content.

Placeholder text

The placeholder text clarifies what content is filtered when searching.

Search bar with “Search messages” placeholder and voice icon.

Input text

The input text contains the characters used to filter a list. Ideally, the list is filtered in real time as each character is typed.

Search bar with entered text “Input text” and clear (X) button.

Trailing accessories

The trailing accessory is optional and provides alternative methods to enter text. The default accessory is a microphone button.

The trailing accessory is replaced with a clear button by default when the field is focused and receives one or more characters.

Microphone icon is replaced by clear (X) button when text is entered.

Behavior

Static search icon

The lead search icon is static and acts as an indicator and affordance of the field’s purpose in place of a label.

4 different states of a search field where each has a persistent search icon at the beginning.

Overflow

Input text overflows horizontally and is masked between the lead and trailing accessories. The cursor remains visible while the field is focused and the input text will adjust in alignment to keep the cursor in view. The input text aligns to the start when the field loses focus.

Search fields with long input that overflows beyond the visible area.

Focus state

Focusing on the search field places the text cursor at the leading edge of the placeholder text. The placeholder text and trailing accessories by default are replaced with a clear button when one or more characters are entered.

Refocusing on the field places the typing indicator at the end of the input value.

Top bar with placeholder, bottom bar with typed text and clear button.

Cancel button

Place a cancel or back button near the search field in search views or similar contexts where users need a clear option to exit the view. This is essential in native search interfaces to provide a straightforward way for users to navigate away from the search.

Mobile search showing results for “coltrane” with three John Coltrane vinyl albums and a clear (X) button in the search bar.

Search button

Include a search button after the search field when a server request and page refresh are necessary. This approach is particularly useful for large datasets in tables, where real-time searching can slow down performance and degrade the user experience.

Search bar with suggestions for “sneakers” and matching bold keywords.

Width

Search fields have a maximum width of 480px and a minimum width of 200px.

Search bars shown at 200px and 480px widths with identical structure.

Screen size

Small screens

Search fields span the full width of the container on smaller screens. The search field should be near the top of the page to ensure there’s enough room for the device keyboard and the first few results to be visible. The screen will scroll to keep the search field in view when receiving focus.

Mobile native app search with keyboard and vinyl results for "coltrane."

Native

Where possible, native platforms use real-time filtering as characters are entered. Native platforms can also leverage a focused search view to reduce unnecessary UI as a search query is entered.

Mobile web search in eBay Watchlist for "coltrane" with results.

Web

Search fields on web platforms filter the list below the field.

Medium and large screens

Medium and large screens across platforms can use the search field inline with other elements, like filter buttons in an action bar.

Desktop Watchlist view with inline search for "chair" results.

Best practices

Search icon visibility

Do keep the lead search icon accessory.

Search icon remains visible while typing.

Don’t hide the lead search icon accessory, even when text is entered.

Search icon hidden while typing.

Search field height

Do use a size that matches adjacent inline elements.

Search field height matches adjacent buttons.

Don’t use a search field that’s a smaller or larger than adjacent inline elements.

Search field height misaligned with adjacent buttons.

Specs

Search bar annotated with padding and spacing for icons and content.