What is a search bar?
A search bar is a single-line text field that takes a query and finds matching content. It looks like a text fieldText fieldAn input where the user types text, like a name, email, password or search query.Open in glossary →, but it behaves differently: what you type is a question to the app, not data to be saved.
Search bars work in one of two ways, and testers must know which one they’re looking at:
- Live filtering: the list below updates as you type (contacts, settings, a list of 50 recipes). No Search key needed.
- Submit search: you type, optionally pick a suggestion, then press Search (Enter) and the app asks the server (shops, maps, mail).
Many apps mix the two: they show suggestions and recent searches while you type, and real results after you submit.
Anatomy
Idle
Typing
- 1
Search icon
The magnifying glass that tells everyone "this field searches". Usually decorative, so screen readers skip it.
- 2
Placeholder
Hint text like "Dishes, restaurants". It disappears as you type, so it can't be the only label.
- 3
Voice search
Optional microphone, shown while the field is empty. Needs microphone permission.
- 4
Scope / filter button
Optional. Narrows what is searched (All, Dishes, Restaurants) or opens filters.
- 5
Query
What the user typed. Single line, scrolls sideways when it gets long.
- 6
Clear button (×)
Appears when there is text. Empties the field and keeps the keyboard open.
- 7
Cancel
iOS only. Leaves search mode and returns to the screen as it was before.
How it differs from similar components
| Component | You type… | You get… |
|---|---|---|
| Search bar | A free-text query | Results, matching or partly matching |
| Text field | Data to save (name, email) | Validation, then the value is stored |
| Combo box | Part of an option’s name | One option from a fixed list (see Dropdown) |
| Filter chips | Nothing, you tap | A narrower list, by fixed categories |
Dev note
iOS has UISearchBar (usually inside a UISearchController) and SwiftUI’s .searchable. Material 3 has a search bar that opens a search view. On the web it’s <input type="search"> inside a form marked with role="search" (or the newer <search> element). Users just say “the search box”.
Designs & variants
All four work correctly. Type, clear, cancel, and try them with only the keyboard (Tab, arrows, Enter, Esc).
Recipes
- Spaghetti carbonara
- Chicken tikka masala
- Pad thai
- Crème brûlée
- Tiramisu
- Apple crumble
iOS search bar
iOSTap the field: the large “Recipes” title slides away to make room, and Cancel and a scope bar (All / Mains / Desserts) appear. The list filters as you type. Like on iOS, Cancel stays even after the keyboard closes; tapping it clears the text and scope and brings the title back.
Ana
Flight to Lisbon: boarding pass
FoodNow
Your pizza is on its way
Marko
Photos from the hike
Bank
Monthly statement
Search bar → search view
Android · Material 3The pill-shaped bar opens a full search view with history. The ↖ arrow copies a suggestion into the field so you can refine it. Back (or Esc) closes the view.
Help center
Type a question and press Search.
Labeled search form
WebA real form with role=search, a visible label, a submit button and a suggestion listbox. Arrow keys move through suggestions, Esc closes them. Search shows the matching articles and announces how many were found.
Expandable search
Web · mobile headersAn icon that turns into a field to save space. Focus must jump into the field on open and back to the icon when it closes.
Focus and the keyboard
The moment a user taps the field, a lot should happen at once, and each part is testable:
- The keyboard opens with a Search key instead of Return.
Dev note
On iOS that’s the search return key type; on AndroidimeOptions="actionSearch"; on the webtype="search"in a form, orenterkeyhint="search". - Auto-capitalization and autocorrect are off. A plain text field capitalizes the first letter and “corrects” words. In a search field that turns iphone into Iphone and airpods into airports.
- The screen switches into search mode: on iOS the large title collapses and Cancel appears; in MaterialMaterial DesignGoogle's design system for Android and the web: the rules for how buttons, tabs, sheets and other components look and behave.Open in glossary → the bar expands into a full search view.
- Recent searches or suggestions appear while the field is still empty.
- The Search key submits the query and usually hides the keyboard, so the results are visible.
Suggestions and recent searches
Suggestions (also called autocompleteAutocompleteSuggestions shown under a field while typing, which the user can pick to finish the input.Open in glossary →) are a list that pops up under the field, so they share the bugs of dropdowns: keyboard navigation, highlighted vs selected, clipped lists. The Dropdown page covers the listbox pattern in detail. Recent searches add their own rules:
- Most recent first, and no duplicates: searching “pizza” twice moves it to the top, it doesn’t add a second row.
- Treat variants as the same search: “Pizza”, “pizza” and “pizza ” are one entry.
- Each entry can be removed, and removed entries stay gone.
- They’re private: after logging out or switching accounts, the next user must not see them.
- Blank searches are never saved.
Clear, Cancel, Back and Esc
| Action | What it should do |
|---|---|
| Clear (×) | Empty the field, clear its results, keep focus and the keyboard |
| Cancel (iOS) | Leave search mode, hide the keyboard, restore the screen exactly as it was |
| Back (Android) | First close the keyboard or search view, then navigate back |
| Esc (web) | Close the suggestions; in some browsers (Chrome, Safari) it also clears a native search field |
Check this part
The list below a search bar updates as you type, without pressing Search. Which kind of search is this?
What is the difference between Clear (×) and Cancel on iOS?
Which recent searches list is correct after searching "pizza", "burger", then "Pizza"?