Search field
A field for typing a query inside a role="search" region, with a leading search icon and a "Clear search" button once it holds text; on listing pages it grows into the search panel.
When to use
- Finding items in a list or a directory by words: guests, people, stations, jobs.
- The top of a listing page: the search panel with a keyword, a location, and the "Search" button (canonical §11 template 4).
- Finding a person in a dialog before choosing them (Global ID's "Find a person"), where the results are radio rows.
When not to use
- Narrowing results by known values (work type, date posted): filter checkboxes or filter chips, which apply at once.
- Choosing one value from a familiar list in a form: a select.
- Typing something that is not a query (an address, a name to save): a text field.
- A suggestion of a ready-made query: a suggestion chip ("Popular searches").
Anatomy
- Search region:
<form role="search">, named for what it searches ("Search jobs"), by its own label or by the field's label. - Label (
<label for>):text-label-md, 6px above the box, says what is searched. - Leading icon:
search, 20px,on-surface-variant, 16px from the inline start; decorative. - Input:
type="search"withenterkeyhint="search", the 56px field box; the value starts 48px from the inline start. - Clear search: a 48px standard icon button with
close, 4px from the inline end, present only while the field holds text. - Helper: what the search matches ("Name or mobile"), 4px under the box.
- Search panel only: an outlined card, the keyword field, a location select, and a filled 56px "Search" button.
Variants
| Variant | Use for | Key tokens |
|---|---|---|
| Search field | lists and directories, dialogs, admin tables | the field tokens, --size-icon-md for the icon |
Search panel (--panel) |
the top of a listing page: keyword, location, "Search" | .oa-card (--radius-card, --color-outline-variant, --color-card-outlined-container), --space-4 |
Sizes
| Size | Height | Padding | Type style | Icon size |
|---|---|---|---|---|
| Field | 56px (h-14) |
48px at the start for the icon (ps-12); 56px at the end while "Clear search" shows (pe-14) |
value text-body-lg; label text-label-md; helper text-body-md |
search 20px; close 24px in a 48px button |
| Panel | the fields and the 56px button in one row from 640px, aligned to the bottom | the card's 20px, 24px from 640px (p-card sm:p-card-medium); 16px between parts |
the field's | — |
The panel's columns from 640px are minmax(0, 1fr) 13rem auto: the keyword takes the space, the location is 13rem (208px), the button keeps at least 112px. Below 640px the parts stack and the button takes the full width (D-CAI-11).
Tokens
| Part | Property | Token |
|---|---|---|
| Field | box, border, fill, radius | --size-field, 1px --color-outline, --color-surface-container-lowest, --radius-field |
| Icon | color, size | --color-on-surface-variant, --size-icon-md |
| Clear search | the standard icon button | --size-button-md, --color-on-surface-variant, the state layer at --opacity-state-hover and --opacity-state-pressed |
| Focus | border, ring | --color-primary-ink, the base ring |
| Placeholder | color | --color-on-surface-variant at full strength |
| Panel | card | --radius-card (rounded-card), 1px --color-outline-variant, --color-card-outlined-container, --space-card, and --space-card-medium |
| Panel | gaps and button | --space-4 (gap-4); the filled large button: --color-primary, --color-on-primary, --size-button-lg |
States
| State | What changes |
|---|---|
| Empty | the icon and the label; "Clear search" is hidden (the hidden attribute) |
| Filled | "Clear search" appears at the inline end; the value keeps 56px clear of it |
| Focus | the field's primary-ink edge and the ring; "Clear search" takes its own ring when focused |
| Hover | no change on the field; "Clear search" shows the 8% layer |
| Error | the field's error edge and message ("Type at least 2 letters or digits.") |
| Disabled | the field's disabled mixes; "Clear search" is disabled with it |
| Searching | the field keeps its value; the results region carries aria-busy and the words say so ("Searching…") |
Behavior
- Enter submits the query; on a phone the keyboard's action key reads "Search" (
enterkeyhint="search"). A listing's search form uses GET, so the query lives in the address and the back button works (canonical §11 template 4). - "Clear search" empties the field, hides itself, and returns focus to the input. It appears as soon as the field holds text (D-CAI-11).
- The browser's own clear button is hidden, so only one control clears the field.
- A list that filters while the person types announces the new count in the page's status region ("15 jobs match these filters."); never move focus while the person types.
- No results: show an empty state that names the query, says why, and offers one way out: "No jobs for “sales manager”" · "Try another word" · "See all jobs" (canonical §12.4).
- The panel stacks below 640px with the button full width, and sits in one row from 640px (D-CAI-11).
- Motion: only color changes, over
duration-short-3withease-standard.
Accessibility
- The form is a search landmark (
role="search") with a name; every field keeps a visible label, even in the panel (canonical §13). - The icon is decorative; "Clear search" is a real button with that name in the page language and the plain tooltip with the same words (icon button).
- The result count is announced through the page's one status region, present from page load (canonical §13).
- A minimum length is said in words before searching: "Type at least 2 letters or digits." (Global ID).
- Targets: the field is 56px, "Clear search" 48px, the panel's button 56px.
RTL and languages
- In Arabic the
searchicon sits at the inline start (right) and "Clear search" at the inline end (left); neither glyph is mirrored (canonical §8.3). - A search field keeps the page direction, so its icon and its padding stay together; a Latin query displays correctly inside an Arabic field. A search for values that are Latin only, such as a Global ID number, sets
dir="ltr"on its control box, as every field does (canonical §10.0). - The panel's grid follows the page direction: the keyword first at the inline start, the button at the inline end.
- Placeholders keep the "For example:" form in each language; in French write a no-break space before the colon.
Content
- Label: what is searched: "Search guests", "Job title, skill or company", "Name or Global ID number".
- Helper: what matches, in a few words: "Name or mobile" / "الاسم أو رقم الهاتف" / "Nom ou mobile"; "Name, email or Global ID".
- Placeholder: an example only: "For example: accountant, nurse, sales" / "مثلًا: محاسب، ممرّض، مبيعات" (Global Jobs) / "Par exemple : comptable, infirmier, ventes" (native review).
- Button: "Search" / "بحث" / "Rechercher" (the glossary; never "Find") (canonical §12.3).
- Clear: "Clear search" / "مسح البحث" (native review) / "Effacer la recherche" (native review).
- Searching: "Searching…" / "جارٍ البحث…" / "Recherche…".
- Region names: "Search jobs" / "ابحث عن وظيفة".
Do and don't
| Do | Don't |
|---|---|
| Give the search field a visible label, even beside a "Search" button. | Rely on the placeholder or the icon to say what the field is for. |
| Show "Clear search" only while the field holds text. | Show both the browser's clear button and your own. |
| Keep the panel's fields and button in one row from 640px. | Let the button wrap under the fields on a desktop window. |
| Announce the result count in the status region. | Move focus to the results while the person types. |
| Name an empty result after the query and offer one way out. | Show a bare "No results". |
Code
HTML (reference CSS)
Empty, and filled with "Clear search" (Global ID's guest list):
<form class="oa-search" role="search" aria-labelledby="sf-guests-label">
<div class="oa-field">
<label class="oa-field__label" id="sf-guests-label" for="sf-guests">Search guests</label>
<div class="oa-field__control">
<span class="oa-field__leading" aria-hidden="true"><span class="oa-icon" translate="no">search</span></span>
<input class="oa-field__input" id="sf-guests" name="q" type="search" enterkeyhint="search" autocomplete="off" spellcheck="false" aria-describedby="sf-guests-hint">
<button class="oa-icon-btn oa-field__trailing oa-search__clear" type="button" aria-label="Clear search" hidden><span class="oa-icon" aria-hidden="true" translate="no">close</span></button>
</div>
<p class="oa-field__message" id="sf-guests-hint">Name or mobile</p>
</div>
</form><form class="oa-search" role="search" aria-labelledby="sf-guests-filled-label">
<div class="oa-field">
<label class="oa-field__label" id="sf-guests-filled-label" for="sf-guests-filled">Search guests</label>
<div class="oa-field__control">
<span class="oa-field__leading" aria-hidden="true"><span class="oa-icon" translate="no">search</span></span>
<input class="oa-field__input" id="sf-guests-filled" name="q" type="search" enterkeyhint="search" autocomplete="off" spellcheck="false" value="Karim Nassar" aria-describedby="sf-guests-filled-hint">
<button class="oa-icon-btn oa-field__trailing oa-search__clear" type="button" aria-label="Clear search"><span class="oa-icon" aria-hidden="true" translate="no">close</span></button>
</div>
<p class="oa-field__message" id="sf-guests-filled-hint">Name or mobile</p>
</div>
</form>The search panel (Global Jobs; the panel is an outlined card):
<form class="oa-card oa-search oa-search--panel" role="search" aria-label="Search jobs">
<div class="oa-field">
<label class="oa-field__label" for="sf-q">Job title, skill or company</label>
<div class="oa-field__control">
<span class="oa-field__leading" aria-hidden="true"><span class="oa-icon" translate="no">search</span></span>
<input class="oa-field__input" id="sf-q" name="q" type="search" enterkeyhint="search" maxlength="120" autocomplete="off" spellcheck="false" placeholder="For example: accountant, nurse, sales">
</div>
</div>
<div class="oa-field oa-field--select">
<label class="oa-field__label" for="sf-location">Location</label>
<div class="oa-field__control">
<span class="oa-field__leading" aria-hidden="true"><span class="oa-icon" translate="no">location_on</span></span>
<select class="oa-field__input" id="sf-location" name="location">
<option value="" selected>All of MENA</option>
<option value="lebanon">Lebanon</option>
<option value="beirut">Beirut, Lebanon</option>
</select>
<span class="oa-field__trailing" aria-hidden="true"><span class="oa-icon" translate="no">arrow_drop_down</span></span>
</div>
</div>
<button class="oa-btn oa-btn--filled oa-btn--lg" type="submit">Search</button>
</form>Arabic:
<div dir="rtl" lang="ar">
<form class="oa-card oa-search oa-search--panel" role="search" aria-label="ابحث عن وظيفة">
<div class="oa-field">
<label class="oa-field__label" for="sf-ar-q">المسمّى الوظيفي أو المهارة أو اسم الشركة</label>
<div class="oa-field__control">
<span class="oa-field__leading" aria-hidden="true"><span class="oa-icon" translate="no">search</span></span>
<input class="oa-field__input" id="sf-ar-q" name="q-ar" type="search" enterkeyhint="search" maxlength="120" autocomplete="off" spellcheck="false" placeholder="مثلًا: محاسب، ممرّض، مبيعات">
</div>
</div>
<div class="oa-field oa-field--select">
<label class="oa-field__label" for="sf-ar-location">الموقع</label>
<div class="oa-field__control">
<span class="oa-field__leading" aria-hidden="true"><span class="oa-icon" translate="no">location_on</span></span>
<select class="oa-field__input" id="sf-ar-location" name="location-ar">
<option value="lebanon" selected>لبنان</option>
<option value="united-arab-emirates">الإمارات العربية المتحدة</option>
</select>
<span class="oa-field__trailing" aria-hidden="true"><span class="oa-icon" translate="no">arrow_drop_down</span></span>
</div>
</div>
<button class="oa-btn oa-btn--filled oa-btn--lg" type="submit">بحث</button>
</form>
</div>Tailwind CSS v4
<form role="search" aria-label="Search jobs" class="grid gap-4 rounded-card border border-outline-variant bg-card-outlined-container p-card sm:grid-cols-[minmax(0,1fr)_13rem_auto] sm:items-end sm:p-card-medium">
<div class="flex min-w-0 flex-col">
<label for="q" class="mb-1.5 text-label-md text-on-surface">Job title, skill or company</label>
<div class="relative">
<span class="pointer-events-none absolute inset-y-0 start-4 flex items-center text-on-surface-variant" aria-hidden="true"><span class="oa-icon oa-icon--md" translate="no">search</span></span>
<input id="q" name="q" type="search" enterkeyhint="search" autocomplete="off" spellcheck="false" placeholder="For example: accountant, nurse, sales" class="block h-14 w-full min-w-0 appearance-none rounded-field border border-outline bg-surface-container-lowest ps-12 pe-4 [&::-webkit-search-cancel-button]:appearance-none text-body-lg text-on-surface placeholder:text-on-surface-variant transition-colors duration-short-3 ease-standard focus:border-primary-ink">
</div>
</div>
<!-- the location select of select.md, with location_on -->
<button type="submit" class="relative isolate inline-flex h-14 w-full min-w-28 items-center justify-center rounded-full border border-transparent bg-primary px-7 text-label-lg text-on-primary sm:w-auto">Search</button>
</form>The filled "Search" button takes the full button recipe with its state layer. In a search field with "Clear search", the input adds pe-14 while the button shows, and the button sits at absolute end-1 top-1. The [&::-webkit-search-cancel-button]:appearance-none variant hides the browser's own clear button, which appearance-none on the input alone leaves in place, so "Clear search" is the only one (D-CAI-11).
React
<SearchField
id="guests"
label={t('admin.guests.search')}
hint={t('admin.guests.searchHint')}
value={query}
onValueChange={setQuery}
clearLabel={t('common.clearSearch')}
/>| Prop | Type | Default | Description |
|---|---|---|---|
id |
string |
required | The input's id. |
label |
string |
required | The visible label; also names the search region unless regionLabel is set. |
regionLabel |
string |
— | The name of the search region when it differs ("Search jobs"). |
value |
string |
required | The query. |
onValueChange |
(value: string) => void |
required | Called as the person types and with '' when cleared. |
onSearch |
(value: string) => void |
— | Called on Enter or the "Search" button; omit for a native GET form. |
clearLabel |
string |
"Clear search" | The name of the clear button, translated. |
hint |
string |
— | What the search matches. |
| placeholder | string |
— | "For example: …" only. |
error |
string |
— | A message such as the minimum length. |
SearchPanel takes regionLabel, action (the listing's address), children (the keyword field and the location select), and submitLabel ("Search").