Skip to content

Search field

BetaFormsOpen in the workshop

Filters the current list as the user types, or searches everything from the topbar.

.xg-input-group > svg.xg-icon + input.xg-input[type=search] (+ .xg-input-group__affix with .xg-kbd)

Example and markup

Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.

Search field
/
Markup
<div class="xg-input-group" style="max-width:320px">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<circle cx="11" cy="11" r="7"/>
<path d="m20 20-3.5-3.5"/>
</svg>
<input class="xg-input" type="search" placeholder="Search campaigns" aria-label="Search campaigns">
<span class="xg-input-group__affix">
<kbd class="xg-kbd">/</kbd>
</span>
</div>

States

Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.

Search field: every state
StateSearch
Empty
Hover
Focus
Filled

When to use it

Use it for

narrowing a table or list; global search in the topbar.

Not for

structured filters (use a Select or the filter bar).

Rules

  • Placeholder names what is searched: “Search campaigns”.
  • Debounce list filtering by about 200 ms; show the number of results.

Accessibility

  • type="search" and an aria-label when there is no visible label. Announce result counts in a polite live region.

Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.

Also in Forms: Input, Textarea, Select, Checkbox, Radio, Switch, Segmented control, Date-range picker, Form layout.

Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).