Search: Guidelines
Search lets people enter a keyword or phrase to get relevant information
Usage
Search helps people find information quickly.
Use search for products with many items to manage, such as files or messages.

Different ways to search
The search entry point is dependent on a product's needs, and should be easy to find:
- Search bar: Use to search contents in a specific view, like Search your messages
- Search app bar: Use this app bar variant when search is the primary, global function
- Search icon button: Use when search is a secondary action or not the main focus



Focused search
When a search entry point is selected, it opens focused search.
- Search suggestions can appear before text is entered
- Search results can show as someone is typing or after a search is executed
- Individual elements maintain their own interaction states when search is focused
More on search states

If search is the primary action, focused search can be a standalone destination reached from a navigation bar.

Search suggestions & results
Search suggestions and results both appear in a list component by default.
To help people find information quickly, consider adding variety and context, such as:
- Leading icons related to suggestions
- Category labels, like Recent, Contacts, or Suggestions
- Avatars or other high-priority items
- Filter chips to narrow down results


Placement
A search bar is typically placed at the top of a screen to remain prominent and accessible. Its location depends on whether search is the primary focus of a product or a secondary action.



Focused search layouts
When focused, search suggestions and results appear in a list below the search bar.
There are two layout options:
- Docked opens a list below the search bar, with a scrim covering main content
- Full-screen expands to fill the screen


Anatomy

- Search bar container
- Leading icon
- Supporting text
- Avatar or trailing icon (optional)
- Input text
- Container for search suggestions or results
Search bar container
In the contained style, the search bar container remains the same shape in both the unfocused and focused states. Avoid changing the container behavior.
The container's margins should be:
- Unfocused: 24dp
- Focused: 12dp
In the divided (baseline) style, a divider separates the search bar and results.

Container color
Search bars use the surface container high color role. This role applies when the screen background is white or a tonal surface color, ensuring the container has clear contrast.

Avoid using a surface container high color on a surface container background. This can cause the search bar to blend in, making it difficult for people to find.
To ensure proper contrast, use surface container roles that are more than one step apart.

Icons & icon buttons
Leading icons
The leading side of a search bar should include either:
- A navigational icon button, such as a menu or arrow
- A non-functional search icon

Trailing icons
A search bar should have one or two trailing icons or icon buttons.
Trailing actions can include:
- Additional modes of searching like voice search
- A separate high-level action such as current location or profile
- An overflow menu
- A decorative search icon



Text
Hinted search text
Provide a short description of the information people can search, like Search replies or Search your messages.
Input text
When a person starts typing, the hinted text is replaced with the input text.
Adaptive design
The search bar position and alignment should scale with the layout, and stay close to the searchable content.
In most cases, a search bar should:
- Stay in its pane and scale in width accordingly
- Internal elements anchor to the left and right as the parent container scales
Focused search
When focused, search can switch between showing suggestions or results in a:
- Docked layout: Best for medium and expanded windows
- Full-screen layout: Default for compact breakpoints

- A docked layout on a large screen
- A full-screen layout, the default for compact screens
Search suggestions or results should swap from full-screen in compact windows to docked in larger breakpoints.
Behavior
Focused search
When a search bar is selected, search becomes focused and can:
- Show historical suggestions before typing
- Show suggestions or results as someone is typing
- Wait to show suggestions or results until a search is queried
The back icon releases focus, dismisses any suggestions or results, and returns the search bar to its original state.
Scroll
Depending on needs, a search bar can:
- Scroll away with content, then reappear when a person begins scrolling up
- Remain fixed at the top of the screen
Search results
To execute a search, a person can:
- Type a query and press Enter
- Select a suggestion or result without querying a search
Search results appear in a list below the bar, and scroll beneath the bar.
For accessibility, focused search needs a clear status indicator that it's searching content, like a search icon or Results label. More on search accessibility

When search results are queried, the input text should remain visible, but not in focus.
Predictive back
On Android, predictive back allows a person to swipe left or right on search.
- Search detaches from the screen edge to signal the full-screen layout will minimize
- The previous screen is revealed in a preview