Skip to content
Bugwise
Menu
UI Components

Search Bar

The field at the top of the screen that finds things. Learn the iOS, Material and web versions, how focus, the keyboard, suggestions, clear and cancel should behave, and the bugs testers find in the field itself.

30 min Inputs & selection iOS · Android · Web Also called: Search field, Search box

Open almost any app and the first thing you see is a grey field with a magnifying glass: Search Amazon, Dishes, restaurants, Search in mail. It’s often the most used control in the whole app, and users expect it to behave exactly like the one in every other app.

It’s also deceptively complex. Behind that one field sit the keyboard, suggestions, recent searches, a clear button, a Cancel button and focus handling. This page is about the field itself. What happens after you search (results, filters, sorting, debounce and race conditions) is covered on the Search, filters & sorting page.

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

Dishes, restaurants
1234

Typing

pizza
Cancel
567
  1. 1

    Search icon

    The magnifying glass that tells everyone "this field searches". Usually decorative, so screen readers skip it.

  2. 2

    Placeholder

    Hint text like "Dishes, restaurants". It disappears as you type, so it can't be the only label.

  3. 3

    Voice search

    Optional microphone, shown while the field is empty. Needs microphone permission.

  4. 4

    Scope / filter button

    Optional. Narrows what is searched (All, Dishes, Restaurants) or opens filters.

  5. 5

    Query

    What the user typed. Single line, scrolls sideways when it gets long.

  6. 6

    Clear button (×)

    Appears when there is text. Empties the field and keeps the keyboard open.

  7. 7

    Cancel

    iOS only. Leaves search mode and returns to the screen as it was before.

How it differs from similar components

ComponentYou type…You get…
Search barA free-text queryResults, matching or partly matching
Text fieldData to save (name, email)Validation, then the value is stored
Combo boxPart of an option’s nameOne option from a fixed list (see Dropdown)
Filter chipsNothing, you tapA 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

iOS

Tap 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 3

The 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

Web

A 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.

SHOPLY

Expandable search

Web · mobile headers

An 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 Android imeOptions="actionSearch"; on the web type="search" in a form, or enterkeyhint="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 Material 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

ActionWhat 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 an <input type="search">

When to use it

A search bar is a good choice when:

  • There’s more content than people can scroll through comfortably: products, contacts, messages, settings.
  • Users know what they’re looking for and can name it (“ramen”, “invoice March”).
  • Search is a main task: then keep the bar visible at the top, not hidden behind an icon.
  • Content has many attributes, so a fixed set of filters can’t cover every question.

Good and bad uses

Search where it saves time

Hundreds of items, many ways to name them.

A shop with thousands of products. Search is the fastest path.

Search for a handful of options

Standard · Express · Pickup

Three options are faster to scan than to type. Show them as a list, radio buttons or a segmented control.

Specific placeholder, real label

The placeholder says what you can search, and screen readers get a proper label.

Vague placeholder as the only label

Type what? Search everything, or only this list? And once you start typing, the hint is gone.

Common bugs

These are the bugs testers report most often in the search field itself.

#BugWhat you seeTypical severity
1Search key does nothingYou press Search/Enter, nothing happens; only tapping a suggestion worksHigh
2Clear (×) leaves stale resultsThe field is empty but old results stay, or × closes the keyboardMedium
3Auto-capitalization / autocorrect on“iphone” becomes “Iphone”, “airpods” becomes “airports”; results are wrong or emptyHigh
4Spaces and case not handled“pizza ” or “PIZZA” finds nothing, although “pizza” worksMedium
5Blank query acceptedPressing Search on an empty or spaces-only field shows everything or an errorLow–Medium
6Duplicate or leaked recents“pizza” three times, deleted entries come back, or the previous user’s searches appearMedium (High if private)
7Cancel doesn’t restore the screenAfter Cancel the selected tab, filter or scroll position is resetMedium
8Stale suggestionsThe list still shows suggestions for an older queryMedium
9Keyboard covers resultsAfter submitting, the keyboard stays open and hides the resultsMedium
10Long text breaks the layoutLong queries push the × or Cancel off-screen, or the results title overflowsLow
11Special characters break itEmoji, diacritics, &, % or " cause errors, wrong encoding or no resultsMedium

Stress-test it

Search bars get the strangest input of any field: typos, emoji, accents, half-sentences, spaces before and after. Try each preset below, look at the request that gets sent, then switch the field settings to fix the problems.

🧪 Query lab

The left side is how the developer configured the field. Type (or tap a preset), press Enter, and see what the server receives. Then fix the settings until every query works.

Field settings

Type:

Request sent

—

Results

—

Tap a preset, then “search ↵” (or press Enter in the field).

Find the bug

This food delivery app has a search bar with six bugs, all in the search field and its lists. Test it like a real user, then like a tester:

  • Type a dish and press Enter (that’s the keyboard’s Search key).
  • Type in lowercase, as most people do on a phone.
  • Search for the same thing twice, and use the recent searches.
  • Use the × button, and try Cancel after choosing a category on the home screen.
  • Search for nothing: just a few spaces.

🐞 Bug hunt: Food delivery search

This demo has 6 hidden bugs. Explore it like a tester, then check your findings.

Found0/6
9:41

Deliver to Ilica 10

Delivery

Popular near you

  • Margherita pizzaLuigi's Pizzeria€9.50
  • Pepperoni pizzaLuigi's Pizzeria€11.00
  • Salmon sushi boxTokyo Bento€14.90
  • Chicken ramenTokyo Bento€12.50
  • Pad thaiBangkok Street€10.90
  • Poke bowlGreen Leaf€12.00
  • Quinoa saladGreen Leaf€9.90
  • Classic burgerGrill House€10.50
  • Veggie burgerGrill House€10.00
  • Chocolate brownieSweet Spot€4.50
  • TiramisuSweet Spot€5.50

Device settings

  1. 1

    Hint: Type "ramen" and press Enter.

  2. 2

    Hint: Search for something, then tap the × in the field.

  3. 3

    Hint: Type "pizza" in lowercase and use "Search for…". Then turn off Auto-Capitalization in the device settings and try again.

  4. 4

    Hint: Search for the same thing twice, or tap a recent search, then look at the list.

  5. 5

    Hint: Choose "Desserts" on the home screen, tap the search field, then tap Cancel.

  6. 6

    Hint: Type only a few spaces, then tap "Search for…". Open recent searches.

How to test it

Checklist

Search bar test checklist

0 of 14 checked

Example test cases

TC-SRCH-001Search key submits the query

Steps

  1. Tap the search field
  2. Type "ramen"
  3. Press the keyboard's Search key

Expected result

Results for "ramen" are shown (Chicken ramen) and the keyboard closes.

TC-SRCH-002Lowercase input stays lowercase on a phone keyboard

Preconditions

  • Real iPhone or Android phone, default keyboard settings

Steps

  1. Tap the search field
  2. Type "pizza"

Expected result

The field shows "pizza" exactly as typed; no capital letter and no autocorrection.

TC-SRCH-003Search ignores case, accents and extra spaces

Steps

  1. Search for "TIRAMISU"
  2. Search for " tiramisu "
  3. Search for "tiramisù"

Expected result

Each search finds "Tiramisu".

TC-SRCH-004Clear button clears text and results

Steps

  1. Search for "sushi"
  2. Tap ×

Expected result

Field is empty, the results are gone, recent searches are shown and the keyboard stays open.

TC-SRCH-005Blank query is ignored

Steps

  1. Tap the search field
  2. Type three spaces
  3. Press Search

Expected result

Nothing is searched, no results page is shown, and no blank entry appears in recent searches.

TC-SRCH-006Repeated search does not duplicate recents

Steps

  1. Search for "pizza"
  2. Search for "burger"
  3. Search for "Pizza"
  4. Clear the field

Expected result

Recent searches show "Pizza" (or "pizza") at the top and "burger" below it, each once.

TC-SRCH-007Cancel restores the previous screen

Steps

  1. Select the "Desserts" category
  2. Scroll the list halfway
  3. Tap the search field and type "cake"
  4. Tap Cancel

Expected result

Search closes, the keyboard hides, "Desserts" is still selected and the scroll position is unchanged.

TC-SRCH-008Recent searches are private to the account

Preconditions

  • User A has searched for "pregnancy test"

Steps

  1. Log out
  2. Log in as user B
  3. Tap the search field

Expected result

User B sees only their own recent searches (or none). Nothing from user A appears.

TC-SRCH-009Long query keeps the field usable

Steps

  1. Paste the long text into the field
  2. Move the cursor to the start
  3. Tap ×

Test data

150 characters, e.g. a pasted product description

Expected result

The text scrolls inside the field, × and Cancel stay visible and tappable, and × clears everything.

Tip: click a test case to expand it.

Accessibility

  • A real label. The placeholder is not a label: it disappears and is often too light. Give the field an accessible name (“Search dishes and restaurants”), and on the web mark the form as a search landmark so screen reader users can jump to it.
    Dev note
    The name comes from a visible label or aria-label; the landmark is role="search" (or <search>).
  • Icon buttons need names. The × must be announced as “Clear text”, the microphone as “Voice search”, the filter as “Filters”, never just “button”.
  • Announce results. After searching, screen reader users need to hear “12 results” or “No results”.
    Dev note
    On the web that’s a polite aria-live region; on mobile an accessibility announcement.
  • Suggestions follow the combobox pattern: arrow keys to move, Enter to choose, Esc to close (see Dropdown).
    Dev note
    role="combobox" on the input, role="listbox" and role="option" for the list.
  • Focus management. Opening a search view moves focus into the field; closing it returns focus to where the user was (the search icon or bar). The focus orderFocus orderThe order in which the Tab key moves through interactive elements.Open in glossary → must stay logical.
  • Touch targetsTouch targetThe area of the screen that responds to a tap, which should be large enough for a finger.Open in glossary →: the × and Cancel are small; their tap area should still be at least 44×44 pt (iOS) / 48×48 dp (Android). On the web, WCAG 2.5.8 (AA) asks for at least 24×24 CSS px; 44×44 px (2.5.5, AAA) is the comfortable target.
  • Contrast: typed text needs 4.5:1. Light grey placeholders often fail; if the placeholder carries information, it needs enough contrast too (WCAGWCAGThe Web Content Accessibility Guidelines, the main international standard for accessibility.Open in glossary →).
  • Voice input is an accessibility feature: dictated text must work like typed text (no trailing period, no capital letter breaking the search).

Mobile vs web

  • Search sits in the navigation bar, often hidden under the large title until you pull down: check users can find it.
    Dev note
    UISearchController with a UISearchBar in the navigation bar, or SwiftUI’s .searchable.
  • Focus shows Cancel and optional scope buttons; Cancel must restore the previous state.
  • Test the Search key, auto-capitalization and autocorrect on a real device, Dynamic Type at the largest sizes, and dictation.
  • Check that scrolling the results dismisses the keyboard when the app is designed to.
  • Material 3 SearchBar expands into a SearchView (full screen on phones, docked on tablets). Older apps use a search icon in the toolbar.
  • The system Back gesture should first close the keyboard or the search view, not leave the screen.
  • Check the keyboard’s action key says Search and submits.
    Dev note
    The action key comes from imeOptions="actionSearch".
  • Test with TalkBack, font scale, different keyboards (Gboard, Samsung Keyboard) and landscape, where the keyboard can cover most of the screen.
  • Some browsers add their own × to a search field and clear it on Esc (Chrome and Safari do; behavior and styling differ between browsers), so check it doesn’t clash with the site’s own ×.
    Dev note
    Use <input type="search"> with a <label>, inside a form with role="search" or a <search> element.
  • Watch for two dropdowns at once: the browser’s autofill history on top of the site’s own suggestions.
    Dev note
    Custom suggestions usually need autocomplete="off".
  • The query normally ends up in the URL (?q=), so Back, refresh and sharing should restore it. Encoding of &, %, # and emoji is a classic bug source. More in Search, filters & sorting.
  • Test keyboard-only use, mobile browsers (does the keyboard show “Go” or “Search”?), and narrow widths.

Check your understanding

Quick quiz

0/5 answered · 0 correct

  1. 1.On a real phone, every search returns "No results", but on a laptop the same search works. What should you check first?

  2. 2.You search for "pizza", then tap the × in the field. What is the correct behavior?

  3. 3.What is the difference between Clear (×) and Cancel on iOS?

  4. 4.Which recent searches list is correct after searching "pizza", "burger", then "Pizza"?

  5. 5.A user types three spaces and presses Search. What should happen?

Key takeaways

  • A search bar is a text field for queries: it should never auto-capitalize or autocorrect, and it should ignore case, accents and extra spaces.
  • Know whether it’s live filtering or submit search; then test the Search key, the ×, Cancel / Back / Esc and focus carefully.
  • Recent searches must be newest first, de-duplicated, removable, free of blanks and private to each account.
  • Suggestions are a listbox: test them like a dropdown, with the keyboard and with fast typing.
  • Always test on a real phone keyboard, with long text, emoji and diacritics, and with a screen reader.

Finished this page?Nice work, this page is complete!

Mark it as done to track your progress. It's saved in this browser, no account needed.

Its review cards are now in Bites ⚡
Esc

Type to search the whole site.