Default
The placeholder says what the field searches.
Lets people search the whole site, or a long list like services, news or publications. It sits in the header or at the top of a results page.
Updated
Search field
<form class="nds-text-input nds-text-input--search" role="search" action="/search" method="get"> <div class="nds-text-input__label-row"> <label class="nds-text-input__label" for="docs-search-live"> Search website </label> <span class="nds-text-input__required" aria-hidden="true"> * </span> </div> <div class="nds-text-input__control-wrap"> <input class="nds-text-input__control" type="search" id="docs-search-live" name="q" placeholder="Search website" /> <button type="submit" class="nds-text-input__search-action" aria-label="Search"> <svg class="nds-text-input__search-icon" aria-hidden="true" focusable="false"> <use href="#nds-icon-search"> </use> </svg> </button> </div></form> A search field is a text input with a search button. The placeholder says what it searches, and a hidden label gives screen readers the same words.
Three states, and an option to show the label. Once people type, a Clear button appears so they can start again.
The placeholder says what the field searches.
Focused, with a 2px border. The Clear button shows once people type.
Use rarely. If search can’t be used, hide it instead.
On a search results page, show the label so people know what they searched.
The properties of Form/Search field. The same in HTML, WordPress and React.
| Property | Type | Possible values | Description |
|---|---|---|---|
| state | string |
| Active is focus, from the browser. There’s no error state: an empty search shows a message, not an error. |
| showLabel | boolean |
| Off in the header, where the label is visually hidden. On for a search results page. |
| placeholder | string |
| Says what it searches, like “Search services”. Search is the only field that uses a placeholder. |
In code, wrap the field in <form role="search">, give the input a <label> (visually hidden when showLabel is off), and make the search button a
real submit button with aria-label="Search". Hide the browser’s own clear button.
| Part | Token | Contrast on the page |
|---|---|---|
| Border | border/strong, 1px | 4.2:1 |
| Border when active | border/dark, 2px | 14.3:1 |
| Search button | surface/muted fill, text/primary icon, 40 × 40 | Over 16.4:1 for the icon |
| Placeholder | text/muted, Body/medium | 6.6:1 |
| Typed text | text/primary, Body/medium (16px) | 17.6:1 |
| Corners · height | radius/050 (4px) · spacing/500 (40px tall) | — |
Say what it searches in the placeholder, like “Search services” or “Search news”.
Don’t show a disabled search field. If search can’t be used, hide it.
Where the search field sits on a page.
How to write the placeholder and the results messages.
“Search services”, not “Search…” or “Type here”.
On the results page: “12 results for ‘passport’”.
Suggest checking the spelling, and link to the full list.
| Write | Don’t write | Why |
|---|---|---|
| Search services | Search... | Says what it searches. |
| 12 results for ‘passport’ | Results | Confirms what was searched. |
| No results for ‘pasport’. Check the spelling or browse all services. | Nothing found | Says how to recover. |
Built on a native input type="search" inside form role="search", so screen readers list it as the
page’s search landmark.
| Key | What it does |
|---|---|
| Tab | Moves to the field, then to the Clear and Search buttons. |
| Enter | Runs the search. |
| Esc | Clears the field in most browsers. |
Copy the code for HTML, WordPress or React from the Code tab in Live example. The options are listed under Specifications.
Use Search field from the NDS Website documentation frames. Match node 900:178577 for states, tokens and copy.
Is this page useful?