Skip to content
menumenu tanreiexpand_morecontrasttranslate
tanreiexpand_more
Getting startedWebReactSwiftUIJetpack ComposeFlutterReact NativePresetsYour own design systemUsing Tanrei with AI agentsBrandDesign tokensDesign systems and customizationTheme StudioColorTypographyIconsShapeElevationMotionInteraction statesBehaviourLayoutAccessibilityWordsColor tokensTypescale tokensShape tokensElevation tokensMotion tokensState tokensSpace and measure tokensComponentsButtonMain action buttonSegmented buttonButton groupButton with menuToolbarCopy buttonCheckboxRadio buttonSwitchChipMenuSliderSlider fieldCalendarDateTimePickerField groupRadio groupCheckbox groupSelectSelect fieldMenubarFile uploadFile picker AdvancedDrop zoneText input AdvancedText fieldChip fieldFieldCombobox AdvancedCombobox fieldNumber input AdvancedNumber fieldColor input AdvancedColor fieldOne-time-code input AdvancedOne-time-code fieldEmbedded text input AdvancedChat composerCardDividerModal layer AdvancedDialogListList rowBottom sheetSide sheetCarouselCode blockTablePopoverStepsAccordionDescription listFigureApp shellPage headerTree viewTimelineImage previewHandleResizable frameScroll areaBadgeProgress indicatorMeterNumber tickerLoading indicatorSnackbarTooltipKeyboard shortcutTagInline codeCalloutAvatarEmpty stateTag groupSkeletonFile itemSwatchMarquee textTabsTab viewApp barNavigation barNavigation drawerSearchLinkPaginationPrevious and next linksStepperBreadcrumbsTable of contentsLink cardFAB menuStatusHow Tanrei is builtContributingLicense and attribution
HomeComponentsSearch

Search

A search bar, or a compact trigger for one, that offers suggestions and results while people type, in a view docked under the bar, in a dialog or over the whole screen.

content_copyView as Markdown
Category
Navigation
Tokens
comp.search
Level
Feature
Built from
Modal layer

Overview

Web
tanrei-search
schedule
SwiftUI
TanreiSearch
schedule
Jetpack Compose
TanreiSearch
schedule
Flutter
TanreiSearch
schedule
React Native
Search
schedule

Generated from docs/status/status.json, specs/search.spec.json

A revised spec, not yet on every platform

This page describes the search as the spec has it now, a site search as well: a trigger in place of the bar, a dialog view, results that are links, a status row and a shortcut. The web component does all of this, and so do the demos. SwiftUI, Compose, Flutter and React Native are marked lagging above: until they catch up they ship the previous revision — the bar with its input, the docked and full-screen views, and suggestions — and their samples show that revision.

Empty, with a query, and with icon buttons

menumicaccount_circle

A site search: a button trigger with its shortcut, an icon trigger, and a bar that shows its shortcut. Press a trigger to open its view

Suggestions under the query row, and inline completion. Type inv, then move with the arrow keys

Usage

The search is a bar and a view. The bar holds a search glyph, the input, a clear button while there is a query, and up to two of your own icon buttons at the end, such as voice input or the account. Your own menu or back button can take the glyph’s place in the leading slot. The view opens while the person searches and holds, from top to bottom, the suggestions, a status row, the results, and then any content of your own.

A bar or a trigger. bar says what stands where the search is placed:

  • field (default): the bar with its input.
  • button: a trigger shaped like the bar that holds no input, only the search glyph, the placeholder and the shortcut hint. Use it in a header that has room.
  • icon: an icon-only button that shows the search glyph. Use it in a header that has none.

A trigger opens a modal view, a dialog or the full-screen view, and the input is in that view’s header. One product uses button on a wide window and icon on a narrow one.

Three presentations. presentation says where the view opens:

  • docked (default): a surface just under the bar, as wide as it, in the platform’s overlay layer, as a menu opens under its anchor. Focus stays in the bar’s input, so the person keeps typing while suggestions change. If there is not enough room below, the view opens above the bar.
  • dialog: a modal surface near the top of the window, over a scrim, with a header that holds a back button, the input and the clear button. It is for a large window, opened from a trigger. A press on the scrim closes it.
  • full-screen: a modal view over the whole window, with the same header. It takes focus, keeps it, and returns it to the bar or the trigger when it closes.

Use docked or the dialog on large windows and full-screen on small ones. The search does not choose for you: set presentation from your own breakpoints. A trigger with docked opens the dialog, because a docked view has no input of its own, and debug builds report it.

Suggestions are an item kind: queries the person may want, such as a past query or a completion of what they typed. Each one has a value, a headline, and optionally supportingText and a leadingIcon, such as history for a past query. You supply the suggestions for the current query; the search draws them and does not filter them. Where a suggestion begins with the query, the part it adds is drawn heavier, as a web search draws it. Choosing one emits select with its value. The search never changes the query itself, so you decide what a choice means: usually, put the suggestion in the bar and search for it.

The query row. While suggestions show, the first row is the query as typed: the search glyph and the query, and under it queryRowText if you give one (“Search all mail”). It is active from the moment the suggestions appear, so Enter always searches for what was typed, as the first row of a browser’s address bar does; Down Arrow goes on to the suggestions. The row needs no words: the glyph and the query are a whole row. Set queryRow to none for the other common form, a web search page’s: there is no such row, nothing is active until the person moves, and Enter searches for what was typed until then.

Moving through the rows. The arrow keys go through the query row, the suggestions and then the results. A suggestion they reach is shown in the input, without changing the query, so Enter chooses what the input shows; back on the query row, the query as typed comes back. At the ends the keys go round: Down Arrow on the last row goes to the first, and Up Arrow on the first to the last. Set wrap to false to stop them at the ends.

Inline completion. inlineCompletion completes the query in the input from the first suggestion that begins with it, the added part selected after the caret, as an address bar does. Moving the caret accepts the completion, Backspace takes it away, and Enter accepts it and searches. It never completes after a deletion or a paste, while an input method is composing, or on an on-screen keyboard. It is off by default.

Results are a second item kind, for the things the search found: a page, a section, a message. A result has a value, a headline, an excerpt and optionally a leadingIcon, and it goes somewhere: with an href its row is a real link, which the platform opens as it opens any link — in a new tab with a modifier key, with its own context menu. Without an href the row is a button, and select is the only signal. A result group puts results under one heading: a quiet title such as “Messages”, or, with an href of its own, the page the results are sections of. The excerpt is a passage in which you mark what matched; the search does not look for the query in the text. On the web the excerpt is the element’s own content with <mark> around the matches, or the excerpt runs, every second one a match.

Status. The search never runs a query, waits or filters: it emits input for every change and draws what you give it. Tell it what your search is doing with status (idle, loading or error) and statusText: the count (“12 results for tokens”), that nothing was found, or the failure. The status row shows the text and announces it when it changes, and while loading it shows a loading indicator after a short delay.

The shortcut. shortcut names the keys that open the search, in the keyboard shortcut’s key names (mod+k, /). The search writes them as a hint, a line of text for the person’s keyboard: at the end of a button trigger, and in the bar while it is empty and not focused. It exposes them as the keyboard shortcut of the trigger or the input. The keys work only if you bind them, or set bindShortcut: the search then listens in the whole window while it is shown and enabled, opens on the keys and closes on them again.

Opening and closing. A press on the bar, typing, or Down Arrow in the input opens the view. Focus alone never opens it: tabbing onto the bar, or focus returning from the full-screen view, leaves it closed. The search asks to open or close with toggle, which carries the new state and, when closing, the reason: escape, back, select, submit, outside, tab, focus-out or shortcut. The query stays as it is when the view closes. While suggestions show, Enter on the query row emits submit with the query as typed; with no suggestions, the first result is the one Enter opens, as in a documentation search. After submit the view stays open while it shows results or a status, so that the person can go on to them. On the web the element sets its own expanded, and on SwiftUI and Flutter the binding or controller changes. On Compose and React Native you set expanded from the callback, as for the menu.

<tanrei-search name="q" label="Search mail" placeholder="Search mail" clear-label="Clear search" query-row-text="Search all mail">
  <tanrei-button variant="text" slot="trailing" label="Search by voice"><span slot="icon">mic</span></tanrei-button>
  <tanrei-search-suggestion value="invoices" headline="invoices" leading-icon="history"></tanrei-search-suggestion>
  <tanrei-search-suggestion value="folder:invoices" headline="Invoices"
    supporting-text="Folder · 24 messages" leading-icon="folder"></tanrei-search-suggestion>
  <!-- Other children are your own content in the view, after the suggestions. -->
</tanrei-search>

<!-- A web search page's form: no query row, nothing active until the person moves; the arrows stop at the ends. -->
<tanrei-search label="Search the web" placeholder="Search" query-row="none" no-wrap></tanrei-search>

<!-- An address bar's form: the query completed in the input from the first suggestion that begins with it. -->
<tanrei-search label="Search or type an address" inline-completion></tanrei-search>

<!-- On a small window: the view covers the window and has a back button. -->
<tanrei-search presentation="full-screen" label="Search mail" placeholder="Search mail"
  clear-label="Clear search" back-label="Back"></tanrei-search>

<!-- A site search: a trigger with its shortcut, a dialog view, and results that are links. -->
<tanrei-search id="docs-search" bar="button" presentation="dialog" label="Search the docs" placeholder="Search"
  shortcut="mod+k" bind-shortcut clear-label="Clear search" back-label="Back">
  <!-- A group with an href is the page; its results are the sections found in it. -->
  <tanrei-search-result-group value="/tokens/" headline="Design tokens" href="/tokens/" leading-icon="article">
    Colors, sizes and motion as <mark>tokens</mark>, in three tiers.
    <tanrei-search-result value="/tokens/#layers" headline="Layers" href="/tokens/#layers" leading-icon="tag">
      A layer changes the value of a <mark>token</mark> and may add its own.
    </tanrei-search-result>
  </tanrei-search-result-group>
  <!-- Other children are your own content, after the results. -->
  <tanrei-button variant="text">Load more results</tanrei-button>
</tanrei-search>

<script type="module">
  import '@tanrei/web/components/search';
  import '@tanrei/web/components/button';
  const search = document.querySelector('[name="q"]');
  search.addEventListener('input', () => showSuggestionsFor(search.value));
  search.addEventListener('submit', () => runSearch(search.value)); // cancelable; inside a form it then submits the form
  search.addEventListener('select', (e) => openSuggestion(e.detail.value));
  // The element sets its own expanded before it fires toggle.
  search.addEventListener('toggle', (e) => log(e.detail.expanded, e.detail.reason));

  // The search never queries, waits or debounces: that is yours.
  const docs = document.querySelector('#docs-search');
  let asked = 0;
  docs.addEventListener('input', async () => {
    const mine = ++asked;
    docs.status = 'loading';
    docs.statusText = 'Searching';
    const found = await query(docs.value);
    if (mine !== asked) return; // a newer question was asked: drop this answer
    show(found); // replace the <tanrei-search-result> children
    docs.status = 'idle';
    docs.statusText = `${found.length} results for ${docs.value}`; // set once per answer: it is announced
  });
  // A result was activated in place. Cancel the event to hand the link to your router.
  docs.addEventListener('select', (e) => { /* e.preventDefault(); router.push(e.detail.value); */ });
</script>
import { Button, Search, SearchResult, SearchResultGroup, SearchSuggestion } from '@tanrei/react';

<Search
  label="Search mail"
  placeholder="Search mail"
  clearLabel="Clear search"
  value={query}
  onInput={(e) => setQuery(e.currentTarget.value)}
  onSubmit={() => runSearch(query)}
  onSelect={(e) => openSuggestion(e.detail.value)}
>
  <Button variant="text" slot="trailing" label="Search by voice" onClick={dictate}><span slot="icon">mic</span></Button>
  {suggestions.map((s) => (
    <SearchSuggestion key={s.value} value={s.value} headline={s.headline} supportingText={s.detail} leadingIcon={s.icon} />
  ))}
</Search>

// A site search: a trigger with its shortcut, a dialog view, and results that are links.
// excerpt is runs of text: every second run is a match.
<Search
  bar="button"
  presentation="dialog"
  label="Search the docs"
  placeholder="Search"
  shortcut={['mod+k']}
  bindShortcut
  clearLabel="Clear search"
  backLabel="Back"
  status={status}
  statusText={statusText}
  onInput={(e) => runQuery(e.currentTarget.value)}
  onSelect={(e) => { e.preventDefault(); router.push(e.detail.value); }}
>
  {pages.map((page) => (
    <SearchResultGroup key={page.url} value={page.url} headline={page.title} href={page.url} leadingIcon="article" excerpt={page.excerpt}>
      {page.sections.map((s) => (
        <SearchResult key={s.url} value={s.url} headline={s.title} href={s.url} leadingIcon="tag" excerpt={s.excerpt} />
      ))}
    </SearchResultGroup>
  ))}
</Search>
import Tanrei

// Every edit writes text; opening and closing write isExpanded.
TanreiSearch("Search mail", text: $query, isExpanded: $isSearching,
             prompt: Text("Search mail"), clearLabel: "Clear search",
             onSubmit: { value in runSearch(value) },
             onSelect: { value in openSuggestion(value) }) {
    TanreiSearchSuggestion("invoices", leadingIcon: "history", value: "invoices")
    TanreiSearchSuggestion("Invoices", supportingText: "Folder · 24 messages", leadingIcon: "folder", value: "folder:invoices")
}
import io.github.chnotchy.tanrei.components.TanreiSearch
import io.github.chnotchy.tanrei.components.TanreiSearchSuggestion

// State hoisting: you keep value and expanded, and move them from the callbacks.
TanreiSearch(
    value = query,
    onValueChange = { query = it },
    expanded = expanded,
    onExpandedChange = { open, _ -> expanded = open }, // the second argument is the reason
    label = "Search mail",
    placeholder = "Search mail",
    clearLabel = "Clear search",
    onSearch = { runSearch(query) },
    onSelect = { openSuggestion(it) },
) {
    TanreiSearchSuggestion(value = "invoices", headline = "invoices", leadingIcon = "history")
    TanreiSearchSuggestion(value = "folder:invoices", headline = "Invoices", supportingText = "Folder · 24 messages", leadingIcon = "folder")
}
import 'package:tanrei/tanrei.dart';

// TanreiSearchController is a TextEditingController that also holds isExpanded.
final TanreiSearchController search = TanreiSearchController();

TanreiSearch(
  controller: search,
  semanticLabel: 'Search mail',
  hintText: 'Search mail',
  clearLabel: 'Clear search',
  onChanged: showSuggestionsFor,
  onSubmitted: runSearch,
  onSelected: openSuggestion,
  suggestions: const <TanreiSearchSuggestion>[
    TanreiSearchSuggestion(value: 'invoices', headline: 'invoices', leadingIcon: 'history'),
    TanreiSearchSuggestion(value: 'folder:invoices', headline: 'Invoices', supportingText: 'Folder · 24 messages', leadingIcon: 'folder'),
  ],
);
import { Search } from '@tanrei/react-native';

// Controlled: you move value and expanded from onChangeText and onExpandedChange.
<Search
  value={query}
  onChangeText={setQuery}
  expanded={expanded}
  onExpandedChange={(next) => setExpanded(next)}
  accessibilityLabel="Search mail"
  placeholder="Search mail"
  clearLabel="Clear search"
  onSubmitEditing={() => runSearch(query)}
  onSelect={openSuggestion}
  suggestions={[
    { value: 'invoices', headline: 'invoices', leadingIcon: 'history' },
    { value: 'folder:invoices', headline: 'Invoices', supportingText: 'Folder · 24 messages', leadingIcon: 'folder' },
  ]}
/>

// On a small window: presentation="full-screen" and backLabel="Back". Android's back button closes the view.

Specs

The docked view with a suggestion, the status row and grouped results, drawn in place

Disabled, and the docked view open

Anatomy

Properties

Property Type Default Description
presentation docked | dialog | full-screen "docked" Where the view opens: docked under the bar, without taking focus from it; dialog, a modal surface near the top of the window with its own header (a large screen, opened from a trigger); or full-screen, over the whole window with its own header (a small screen). One product uses more than one and switches by window size.
bar field | button | icon "field" What stands where the search is placed. field: the bar with its input, as before. button: a trigger shaped like the bar that holds no input — the search glyph, the placeholder and the shortcut hint — for an app bar with room. icon: an icon-only Button showing the search glyph, for an app bar without. A trigger opens a modal view (dialog or full-screen), where the input is. One product uses button on a wide window and icon on a narrow one.
value string "" The query.
label string "" Names the search field, the trigger, the view, the suggestions and the results for assistive technology ("Search mail"). Drawn only as a button trigger's text while placeholder is empty. Required.
placeholder string "" A hint shown while the value is empty, and the text of a button trigger. Never a replacement for label.
expanded boolean false Whether the view is open. The search asks to open and close it with toggle (SRC-5, SRC-6, SRC-36, SRC-38).
disabled boolean false Prevents focus, editing and opening the view.
clearLabel string "" The clear button's accessible name, in the product's language ("Clear search"). Required while the clear button can show.
backLabel string "" The accessible name of the back button in a modal view's header ("Back"). Required for full-screen and for dialog.
shortcut strings The keyboard shortcut that opens the search, in the keyboard shortcut component's key names: one chord per string, pressed in order (["mod+k"], ["/"]). The search writes it as a hint, a line of text with no keycaps (SRC-37), and exposes it as the keyboard shortcut of its trigger or input. It makes the keys work only while bindShortcut is true (SRC-38); otherwise the product binds them.
bindShortcut boolean false Makes the search itself listen for shortcut, anywhere in the window, for as long as it is shown and enabled: the keys open it, and close it again while it is open (SRC-38). Off by default: a component listens outside itself only where the product asks it to.
status idle | loading | error "idle" What the product's search is doing, which the product sets: idle (nothing is awaited: results, or none, are final), loading (a query is running: the status row shows a loading indicator after its delay) or error (the query failed: statusText is drawn as an error and announced at once). The search never runs a query itself (SRC-51).
statusText string "" The status row's text, in the product's language, announced to assistive technology when it changes: the count ("12 results for tokens"), that nothing was found ("No results for tokne"), the failure ("Search is unavailable"); while loading, the loading indicator's name ("Searching"). Empty draws no status row unless status is loading.
queryRow first | none "first" Where the query as typed stands among the suggestions, which are queries. first: a row of its own above them — the search glyph and the value, with queryRowText under it — drawn while the view shows suggestions and the value is not empty, and active from the moment they show, so that the action key always searches for what was typed, as the first row of a browser's address bar does (SRC-57). none: no such row: no suggestion is active until the person moves to one, so that the action key searches for what was typed until then, as a web search page does, and the input itself is the place before the first suggestion in the arrow keys' cycle (SRC-14).
queryRowText string "" What the query row says beside the query, in the product's language, drawn as its supporting text and read as its description ("Search all mail", "Ask the assistant"). Empty draws the search glyph and the query alone: the row needs no words. Ignored while queryRow is none.
inlineCompletion boolean false Completes the query in the input while the person types, from the first suggestion whose headline begins with it: the rest of that headline is written after the caret, selected, and the query row shows the completed query (SRC-55). A completion of the beginning only; never after a deletion or a paste, during an input-method composition or on an on-screen keyboard; moving the caret accepts it, Backspace takes it away. Off by default: an address bar completes, a search page does not. Ignored while queryRow is none.
wrap boolean true Whether the arrow keys go round at the ends of the view's rows: Down Arrow on the last to the first, Up Arrow on the first to the last — with queryRow none, through the input's own place before the first suggestion (SRC-14, SRC-49). False stops them at the ends.
iconSpace auto | always | never "auto" Whether a row of the view — a suggestion, a result, a result group's linked heading — keeps the room of the leading icon column where it has no icon, so that the headlines of the view start on one line. auto: every row keeps the column while any suggestion or result of the view has a leading icon, and none while none has. always: every row keeps it. never: only a row that has an icon has the column. The view is decided as a whole. The menu's iconSpace, with the same values and default (SRC-52).
density regular | compact "regular" How much room a row of the view takes — a suggestion, a result, a result group's linked heading —: its least height, its paddings, the gap after its icon column and the size of its glyph, and never its text style. regular (a 56 row in the default system) is for a product used by touch as well as by pointer; compact (a 32 row with a 20 glyph, the tree view's compact row) is for a tool used with a pointer, a command palette looked through with the keyboard. For touch a row is never lower than the touch target in either (SRC-16). The bar, the trigger and the view's header are not changed. A design system may add values.

Slots

Slot Description
leading An icon-only Button at the bar's start (a menu or back button), drawn in place of the search glyph.
trailing Up to two icon-only Buttons at the bar's end, after the clear button (voice input, account).
default The product's own content in the view, after the suggestions, the status row and the results: a button that loads more results, a link to the full results page, or richer content for an empty query.

Events

Event Description
input The person changed the value (typing, deleting, pasting, dictating, the clear button, Escape); carries the new value. Not emitted when the product sets value. It is the product's cue to run its query; the search does not delay or drop it (SRC-51).
submit The person pressed the keyboard's action key (Enter, Search) with no suggestion active and no result current; carries the value.
select The person chose a suggestion, or activated a result in place (without a modifier key, in the same window); carries its value. For a result with an href it is emitted before the platform follows the link, and on the web cancelling it keeps the link from being followed, so that a router can take it.
toggle The search asks to open or close its view; carries the new expanded value and, when closing, the reason: escape, back, select, submit, outside, tab, focus-out or shortcut (in the platform's casing).

Items

The kinds of item the component repeats. A fixture lists its items in order; each platform names each kind in its own idiom.

suggestion

A choice that completes or replaces the query while the person types: a query they searched before, or a completion. Choosing it emits select and the product sets the value. A thing the product opens is a result.

Property Type Default Description
value string "" Identifies the suggestion; select carries it. Unique among the suggestions.
headline string "" The suggestion's text, and its accessible name.
supportingText string "" A second line under the headline ("Folder · 24 messages"), and its description.
leadingIcon string "" The name of a glyph at the row's start (history for a past query, a folder for a result). Empty draws none.
Spec Web SwiftUI Jetpack Compose Flutter React Native
Item tanrei-search-suggestion TanreiSearchSuggestion TanreiSearchSuggestion TanreiSearchSuggestion SearchSuggestion
value · Property value value value value value
headline · Property headline headline headline headline headline
supportingText · Property supportingText supportingText supportingText supportingText supportingText
leadingIcon · Property leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
Notes A child element with value, headline, supporting-text and leading-icon attributes, as <option> in a <datalist>. TanreiSearchSuggestion(_ headline:, supportingText:, leadingIcon:, value:) in the suggestions view builder. TanreiSearchSuggestion(value, headline, supportingText, leadingIcon) called in the search's content lambda, before the product's own content. TanreiSearchSuggestion(value:, headline:, supportingText:, leadingIcon:) in the search's suggestions: list. The element type of the suggestions array: { value, headline, supportingText?, leadingIcon? }.

result

A thing the search found that the person can go to: a page, a section of a page, a message, a file. It is a link, not an option.

Property Type Default Description
value string "" Identifies the result; select carries it. Unique among the suggestions, results and result groups.
headline string "" The result's title, and its accessible name.
excerpt strings A passage of the thing found, as runs of text in order: the first, third, fifth… run is plain text and the second, fourth… is a match, drawn marked (SRC-43). ["Tokens are ", "design", " decisions"] marks design; a passage that begins with a match begins with an empty run; one run alone is a passage without marks. The product's search decides what matched; the search component does not look for the query in the text.
leadingIcon string "" The name of a glyph at the row's start (article for a page, tag for a section). Empty draws none.
href string "" Where the result goes: an address as the platform's links take one (a URL; on the web a path or a fragment as well), in the prop set every control with a destination takes. Not empty, it makes the row a link, opened by the platform as its own links are (SRC-45). Empty makes the row a button: select is then the only signal, and the product opens the thing.
target same | new "same" Where the destination opens. same: where the person is. new: a new context — a new tab or window on the web, outside the current screen elsewhere — which targetLabel says. Ignored without href.
targetLabel string "" What assistive technology reads after the result's name while target is new ("opens in a new tab"), in the product's language. Required while target is new; ignored otherwise.
Spec Web SwiftUI Jetpack Compose Flutter React Native
Item tanrei-search-result TanreiSearchResult TanreiSearchResult TanreiSearchResult SearchResult
value · Property value value value value value
headline · Property headline headline headline headline headline
excerpt · Property excerpt excerpt excerpt excerpt excerpt
leadingIcon · Property leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
href · Property href destination href href href
target · Property target target target target target
targetLabel · Property targetLabel targetLabel targetLabel targetLabel targetLabel
Notes A child element whose link is an <a href> (a <button> without href) it keeps as its own first child in the light DOM, drawn as nothing and slotted over the row it draws in its shadow root, so that the search's input can name it as its active descendant (SRC-50); a page's rules for anchors and buttons neither move nor paint it. The excerpt is its child content: text with <mark> elements for the matches, which is what search engines hand back, styled through ::slotted(mark); the excerpt property (an array of runs) is used while it has no child content. Inserting an engine's HTML is the product's act: the element never parses a string as markup. rel and download are forwarded to the anchor, as every link form forwards them; target="new" is target="_blank" with noopener in rel. Not built on this platform yet. TanreiSearchResult(_ headline:, excerpt: [String], leadingIcon:, value:, destination: URL?); with a destination it opens through the environment's openURL and has the .isLink trait. target and targetLabel as the platform's link forms map them. Not built on this platform yet. TanreiSearchResult(value, headline, excerpt: List<String>, leadingIcon, href); with an href it opens through LocalUriHandler. target and targetLabel as the platform's link forms map them. Not built on this platform yet. TanreiSearchResult(value:, headline:, excerpt: [...], leadingIcon:, href: Uri?, target:, targetSemanticLabel:) in the search's results: list, with Semantics(link: true). Not built on this platform yet. An element type of the results array: { value, headline, excerpt?, leadingIcon?, href? }, with accessibilityRole="link"; an href opens through Linking. target and targetLabel as the platform's link forms map them.

result-group · group — holds items

Results that belong together, under one heading: the sections found in one page, or the results of one kind. With an href its heading is itself a result (the page), and its results are drawn under it as its parts; without one its heading is a title.

Property Type Default Description
headline string "" The group's heading: the page's title, or the name of the kind ("Pages"). It names the group for assistive technology.
value string "" Identifies the heading as a result while href is not empty; select carries it.
excerpt strings While href is not empty, the heading's own excerpt, in the runs a result's excerpt has. Ignored without href.
leadingIcon string "" While href is not empty, the name of a glyph at the heading row's start. Ignored without href.
href string "" Where the heading goes. With it the heading is a result's row and a link (SRC-44, SRC-45); empty makes it a title that takes no input.
target same | new "same" Where the destination opens. same: where the person is. new: a new context — a new tab or window on the web, outside the current screen elsewhere — which targetLabel says. Ignored without href.
targetLabel string "" What assistive technology reads after the result's name while target is new ("opens in a new tab"), in the product's language. Required while target is new; ignored otherwise.
Spec Web SwiftUI Jetpack Compose Flutter React Native
Item tanrei-search-result-group TanreiSearchResultGroup TanreiSearchResultGroup TanreiSearchResultGroup SearchResultGroup
headline · Property headline headline headline headline headline
value · Property value value value value value
excerpt · Property excerpt excerpt excerpt excerpt excerpt
leadingIcon · Property leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
href · Property href destination href href href
target · Property target target target target target
targetLabel · Property targetLabel targetLabel targetLabel targetLabel targetLabel
Notes A child element holding <tanrei-search-result> children; with href its own heading's link is an <a> it keeps as its own child, as a result does, and its excerpt is the content of its excerpt slot, with <mark> as in a result. Not built on this platform yet. TanreiSearchResultGroup(_ headline:, destination:, …) { results }. Not built on this platform yet. TanreiSearchResultGroup(headline, href, …) { results }. Not built on this platform yet. TanreiSearchResultGroup(headline:, href:, results: [...]). Not built on this platform yet. The other element type of results: { headline, href?, …, results: [...] }.

States

Behavior

Requirements in EARS form. Every platform implementation is tested against these ids.

ID Requirement
SRC-1 THE search SHALL draw its bar as wide as its layout gives it and at least comp.search.container.height high, filled with comp.search.standard.container.color, raised by comp.search.standard.container.elevation and rounded by comp.search.container.shape, and SHALL lay out in one row, each element vertically centered and comp.search.container.gap from the next, except that its action buttons — the clear button and the icon-only Buttons of the trailing slot — stand comp.search.container.button-gap from one another (SRC-34): the search glyph comp.search.container.padding-inline from the start edge (or, WHILE the leading slot is filled, the product's icon-only Button comp.search.container.padding-inline-with-button from it, in place of the glyph), the input taking the remaining width, the clear button WHILE it is shown (SRC-10), and the icon-only Buttons of the trailing slot; the last element SHALL end comp.search.container.padding-inline-with-button from the end edge when it is an icon-only Button, and comp.search.container.padding-inline when it is the input. Right-to-left layouts SHALL mirror the row.
SRC-2 THE search SHALL draw the glyph search of the system's icon set at comp.search.leading-icon.size in comp.search.standard.leading-icon.color with the family and fill of an unselected icon, sys.icon.weight and an optical size clamped between sys.icon.optical-size.min and sys.icon.optical-size.max, SHALL NOT mirror it when the layout direction is right-to-left, and SHALL hide it from assistive technology. THE search SHALL draw no mark of its own (no path, shape or character of its own) for this glyph or for the glyphs of its clear and back buttons (SRC-10, SRC-11).
SRC-3 THE search SHALL draw the value on one line in comp.search.input.typescale and comp.search.standard.input.color, scrolling it sideways inside the input when it is longer, and WHILE the value is empty the placeholder in the same text style in comp.search.standard.placeholder.color; it SHALL draw the caret in comp.search.standard.caret.color and highlight selected text in comp.input-box.selection.color, drawing it in comp.input-box.selection.content.color: the product's one selection pair for text entry.
SRC-4 THE search SHALL edit its value in the platform's native text element and SHALL follow the text field's rules for it: TXI-1 (input once per change, and none when the product sets value), TXI-4 (input-method composition), TXI-20 for the search type (a general keyboard whose action key reads as search) and TXI-24 (the typed text's own direction); it SHALL hide a clear or cancel button that the platform draws inside its native element (the web's search cancel button), because it draws its own (SRC-10).
SRC-5 WHILE collapsed and bar is field, WHEN the person presses the bar outside its slot elements and the clear button, types into the input, or presses Down Arrow in it, THE search SHALL focus the input and emit toggle once with expanded true; focus that reaches the input by Tab, or returns to it when the view closes, SHALL NOT expand it. The Down Arrow that opens the view SHALL only open it: the row the action key takes is then the one SRC-14 and SRC-49 make current as the view opens, made current by an arrow key and so announced at once (SRC-24). THE search SHALL become expanded through its binding or controller where expanded is one (SwiftUI, Flutter) and by setting its own property on the web, and by the product setting expanded to true on Compose and React Native. WHILE bar is button or icon the trigger's activation is what expands the search (SRC-36), and the product's shortcut where the search binds it (SRC-38).
SRC-6 WHILE expanded, WHEN the person presses Escape or the platform's back, activates the back button (SRC-11), chooses a suggestion (SRC-15), activates a result in place (SRC-45), submits where submitting closes (SRC-13) or presses the shortcut the search binds (SRC-38), or, WHILE presentation is dialog, presses the scrim (a modal view answers Escape, back and the scrim as its modal layer does, MDL-6), or, WHILE presentation is docked, presses outside the bar and the view, presses Tab or Shift+Tab, or moves focus out of the search, THE search SHALL emit toggle once with expanded false and that reason (escape, back, select, submit, shortcut, outside, tab or focus-out) and SHALL be collapsed as SRC-5 says it is expanded; the value SHALL stay as it is. Tab and Shift+Tab SHALL then move focus on from the input as they would have, and whether a press outside also reaches the element under it SHALL follow the platform and be stated in its README, as for the menu (MNU-5). Focus that moves between the bar's input and a result of the docked view (SRC-49) has not left the search.
SRC-7 WHILE expanded, presentation is docked and bar is field and the view has content (a suggestion, a status row, a result, a result group, or content in the default slot), THE search SHALL present the view in the platform's overlay layer, the one the menu's surface uses (MNU-1), comp.search.view.offset below the bar, as wide as the bar and aligned with it; WHERE the room below, within comp.search.view.viewport-margin of the viewport's edge and of the on-screen keyboard, is less than the view needs and the room above is more, it SHALL place the view above the bar instead; it SHALL limit the view's height to the room left and scroll its content beyond it, and keep following the bar while it moves. It SHALL fill the view with comp.search.view.container.color, raise it by comp.search.view.container.elevation, round it by comp.search.view.container.shape, clip the content to that shape and inset it by comp.search.view.padding-block and comp.search.view.padding-inline. WHILE the view has no content THE search SHALL draw no view and stay expanded.
SRC-8 WHILE presentation is docked THE search SHALL keep focus in the bar's input while the view is open, because the view is an operated overlay whose focus is the input it belongs to: it SHALL NOT move focus into the view when it opens, trap focus, make anything inert or draw a scrim; a press on a suggestion, on the status row or on the view's surface SHALL NOT take focus from the input; a result is a link and takes focus when the person presses it or reaches it by Down Arrow (SRC-49), which is still focus inside the search; and the search SHALL leave focus where the person put it when the view closes.
SRC-9 WHEN expanded becomes true WHILE presentation is full-screen THE search SHALL present the view over the whole window as a modal overlay on its modal layer without the layer's scrim (MDL-1 WHILE scrim is false, the view filling the window), filled with comp.search.view.container.color to every edge of the window and under every system inset, with its content inside the safe area and above the on-screen keyboard: at its top a header at least comp.search.header.height high holding the back button (SRC-11) comp.search.header.padding-inline from the start edge, the input with the same value, and the clear button WHILE it is shown, the last of them comp.search.header.padding-inline from the end edge, comp.search.container.gap apart and vertically centered; under the header a line of comp.search.divider.thickness in comp.search.divider.color across the window; under that the view's content in the order SRC-46 gives, scrolling. It SHALL move focus to the header's input with the caret at the end of the value, keep focus inside the view, and make everything outside it inert and hidden from assistive technology, as its modal layer does (MDL-2, MDL-4); WHEN the view closes THE search SHALL return focus to the bar's input without expanding it again (SRC-5), or to the trigger WHILE bar is button or icon.
SRC-10 WHILE value is not empty and disabled is false THE search SHALL show a clear button: an icon-only Tanrei Button of the text variant showing the glyph close of the system's icon set, not mirrored, named by clearLabel, of size small in the bar and medium in the full-screen header. WHEN it is activated THE search SHALL set value to empty, emit input once with the empty value and move focus to the input it belongs to, and SHALL NOT expand or collapse. WHILE clearLabel is empty THE search SHALL still show the button, and in debug builds report that it has no accessible name.
SRC-11 WHILE the full-screen view is open THE search SHALL draw a back button at the start of its header: an icon-only Tanrei Button of the text variant and the medium size showing the glyph arrow_back of the system's icon set, mirrored in right-to-left layouts by the icon helper, as the icon set marks it (SRC-32), named by backLabel; WHEN it is activated THE search SHALL collapse with the reason back (SRC-6). WHILE backLabel is empty THE search SHALL still draw it, and in debug builds report that it has no accessible name.
SRC-12 WHILE collapsed and the input has focus, WHEN the person presses Escape with a value that is not empty THE search SHALL set value to empty and emit input once, as a native search input does; with an empty value Escape SHALL do nothing and pass on to the enclosing element.
SRC-13 WHEN the person presses the keyboard's action key (Enter, Search, Go) in the input while the query row is active or no row is (SRC-14, SRC-57), no result is current (SRC-49) and no input method is composing, or presses the query row by pointer or touch, THE search SHALL, WHILE an inline completion is shown, first accept it (SRC-55), and SHALL emit submit once with the value and then, WHILE expanded and the view shows no result, no result group and no status row, collapse with the reason submit (SRC-6), so that toggle follows submit; WHILE the view shows one of them it SHALL stay expanded, because what the person asked for is already in front of them, and the product closes the view where its submit goes elsewhere; on the web, inside a form, it SHALL then request the form's submission unless submit was cancelled, as a native input does. The submission SHALL be requested through the form's default button (BTN-30): WHILE the form has a submit button — the platform's own or a Button of type submit — the first of them in document order SHALL be pressed, so that its click is emitted and its name and value are sent, and WHILE that button is disabled nothing SHALL be submitted; only a form with no submit button is asked directly.
SRC-14 WHILE expanded and the view holds suggestions THE search SHALL keep focus in the input, so that typing goes on editing the value, and SHALL make at most one of its rows current without moving focus, as an editable combobox with list autocomplete does. The rows the arrow keys go through are, in this order: the query row WHILE it is drawn (queryRow first and a value that is not empty, SRC-57), and otherwise the input's own place, which stands for the value as typed and makes no row current; then the suggestions, in the product's order; then the results (SRC-49). WHEN the input has focus and the view comes to show suggestions — it opens with them, the product gives or replaces them, or focus comes back to the input — and WHEN the person types, deletes or pastes, THE search SHALL make the first of those places current automatically: the query row, active, or the input's place, no row being active — either way the action key searches for the value as typed (SRC-13). Down Arrow SHALL make the next row current and Up Arrow the previous one, Down Arrow from the input's place going to the first suggestion and Up Arrow on the first suggestion back to the input's place; WHILE wrap is true Down Arrow on the last row SHALL go to the first place and Up Arrow on the first place to the last row, and WHILE wrap is false they SHALL do nothing at the ends. WHEN a suggestion becomes active by an arrow key THE search SHALL show its headline in the input in place of the value, the caret at its end, without changing value or emitting input, so that the action key chooses what the input shows (SRC-15); WHEN the query row or the input's place becomes current again, or a result takes focus, THE search SHALL show the value as typed again (and its inline completion, SRC-55); WHEN the person types, deletes or pastes while a suggestion's headline is shown, that text, edited, SHALL become the value (input, SRC-4); and WHEN the view closes or the input loses focus without a choice THE search SHALL show the value as typed. Moving the caret SHALL leave the current row as it is, except that it accepts an inline completion (SRC-55). WHILE the person types on an on-screen keyboard THE search SHALL make no row current by itself — neither as the suggestions show nor as the person types — so that the keyboard's action key (Search, Go) submits the value as typed (SRC-13), as a search field on a phone does, and the person chooses a suggestion by touching it. The person types on an on-screen keyboard from the moment the input takes focus from a touch or a pen (or a touch or a pen presses the focused input), and no longer once they press Down Arrow, Up Arrow or a key that moves the caret — keys only a hardware keyboard has — or a mouse presses the input, which make the first place current as after typing: whether a device has a touch screen, or a coarse primary pointer, does not tell which keyboard is in use on a laptop with a touch screen or a tablet with a keyboard attached. WHILE no row is current because of an on-screen keyboard, Down Arrow SHALL make the first row current (the query row, or the first suggestion where the input's place comes first) and Up Arrow the last row WHILE wrap is true. WHILE an input method is composing no row SHALL be current and Enter, Escape and the arrow keys SHALL be the input method's (TXI-4), so that the Enter that confirms a conversion chooses nothing; WHEN the composition ends THE search SHALL make the first place current as after typing. WHILE the input does not have focus no row SHALL be current. WHEN a row becomes current while part of it is scrolled out of view THE search SHALL scroll it into view. Enter with an active suggestion SHALL choose it (SRC-15). A row made current automatically is announced once typing pauses, and one an arrow key moves to at once (SRC-24).
SRC-15 WHEN the person activates a suggestion (by pointer or touch, or by Enter while it is active) THE search SHALL emit select once with the suggestion's value and then collapse with the reason select (SRC-6), so that toggle follows select; it SHALL NOT change value itself: the product sets the value it wants, the suggestion's text for a query. The query row is not a suggestion: activating it submits the value (SRC-13, SRC-57).
SRC-16 THE search SHALL lay out each suggestion as one row, at least comp.search.suggestion.container.height.regular tall and at least sys.target.touch tall for touch input, in both densities, and for fine pointers at least sys.target.pointer tall WHILE density is regular and as tall as its density gives WHILE density is compact (SRC-53) (rows that touch cannot extend a hit area over each other): comp.search.suggestion.container.padding-inline.regular from each edge, the leading icon column as SRC-52 says, then the headline with the supporting text under it, comp.search.suggestion.container.gap.regular after the icon column, padded by comp.search.suggestion.container.padding-block.regular above and below. It SHALL draw the headline in comp.search.suggestion.headline.typescale and the supporting text in comp.search.suggestion.supporting-text.typescale, both wrapping and growing the row rather than being cut; the leading icon at comp.search.suggestion.leading-icon.size.regular with the family and fill of an unselected icon, sys.icon.weight and an optical size clamped between sys.icon.optical-size.min and sys.icon.optical-size.max; and the row's highlight rounded by comp.search.suggestion.container.shape. Right-to-left layouts SHALL mirror the row, and the whole row SHALL be the suggestion's hit area.
SRC-17 WHILE a suggestion — the query row included — is hovered, active or pressed THE search SHALL render its container, leading icon, headline, supporting text and opacity from the component tokens of its highest-precedence state, with precedence pressed over active over hovered and the active suggestion taking the focused tokens; WHEN a suggestion becomes active THE search SHALL show the focus ring inside its row without animation, whether an arrow key or the search made it active. A pointer over a suggestion SHALL NOT make it active.
SRC-18 WHILE the bar is hovered, focused or pressed THE search SHALL render its container, outline, outline width, glyph, input, placeholder, caret and opacity from the component tokens of the highest-precedence active state, with precedence pressed over focused over hovered; unlike a button, focus gained by pointer or touch SHALL select the focused state, because a field shows where typing will go however it was focused. THE search SHALL show the bar's focus by its focused outline, drawn inside the bar's edge, and SHALL NOT draw the focus ring around the bar; WHERE sys.behavior.focus-style is glow it SHALL also draw the glow around the bar while it is focused. WHEN colors or widths change between states THE search SHALL animate them over comp.search.motion.state-duration with comp.search.motion.state-easing, and at once where motion is reduced.
SRC-19 WHEN the bar is pressed by pointer or touch, or a suggestion by pointer, touch or Enter, THE search SHALL show that element's pressed state without delay and SHALL keep it visible for at least sys.motion.duration.press-hold, even when the press ends sooner.
SRC-20 WHILE pressed THE search SHALL answer as sys.behavior.pressed-feedback names: overlay applies the pressed tokens to the whole container at once; ripple grows the pressed state layer from the point of contact (from the center for keyboard activation); dim applies the pressed opacity to the whole control and draws no state layer; none draws no answer to the press. Under ripple and dim only the container color stays with the state under the press; outline, glyph, input, placeholder, caret, leading icon, headline, supporting text, opacity and shape still come from the pressed tokens. Under none every part stays with the state under the press. The ripple grows over comp.search.motion.feedback-duration with comp.search.motion.state-easing, fades over comp.search.motion.state-duration with comp.search.motion.state-easing once the press has ended and press-hold has passed, and appears whole where motion is reduced. The container is the bar for a press on the bar and the row for a press on a suggestion; the control a dim applies to is the bar or the row.
SRC-21 THE search SHALL ease its bar, view and suggestion corners by sys.shape.corner-smoothing (0 is a quarter circle, 0.6 the iOS continuous corner; a platform with only the OS curve draws it for any amount above 0) and show its keyboard focus as sys.behavior.focus-style names (ring or glow); a platform that cannot draw a choice SHALL fall back to the first value and state that in its README.
SRC-22 WHERE the bar is shorter than the minimum target THE search SHALL extend its hit area vertically to sys.target.touch for touch input and sys.target.pointer for fine pointers, without changing its visual size; a platform that cannot tell the input type SHALL use sys.target.touch.
SRC-23 WHEN the view opens THE search SHALL fade it in over comp.search.motion.open-duration with comp.search.motion.open-easing, a docked view also growing from its edge that faces the bar, and WHEN it closes SHALL fade it out over comp.search.motion.close-duration with comp.search.motion.close-easing; WHERE motion is reduced it SHALL appear and disappear at once. Focus SHALL move (SRC-9) when the view opens or closes, not when the motion ends.
SRC-24 THE search SHALL expose its input as a search field named by label and never by placeholder, with the platform's search role where it has one (a search box, the search-field trait, the search input type); WHILE the view shows suggestions, the web's input SHALL be a combobox with aria-autocomplete list (both WHILE an inline completion can be shown, SRC-55), aria-expanded true and aria-controls naming the suggestions' listbox. THE search SHALL announce the active row, as the input's active descendant on the web: at once WHEN an arrow key makes it active; and WHEN the search made it active automatically (the query row, SRC-14) only once it has stayed active for 500 milliseconds with nothing typed, each edit taking the active descendant away until then, as React Aria's autocomplete does, so that a screen reader reads the character typed first and then what the action key takes, and not a row after every key. The active option SHALL be selected (aria-selected true) and every other one not, from the moment it is active. THE search SHALL expose the suggestions on the web as a listbox named by label whose options — the query row first where it is drawn (SRC-57), then the suggestions — are named by their headline and described by their supporting text, and on the other platforms as buttons named and described the same way, with their position in the list; icons and the divider SHALL be hidden; WHILE the view shows no suggestion the web's input SHALL be a search box without the combobox role, whatever else the view holds; results SHALL never be options (SRC-50); the dialog and full-screen views SHALL each be exposed as their modal layer's modal dialog (MDL-10) named by label; the clear and back buttons SHALL be named by clearLabel and backLabel.
SRC-25 THE search SHALL NOT restyle the icon-only Buttons in its leading and trailing slots: each SHALL render from its own tokens and keep its own semantics and its own focus stop in reading order (the leading one before the input, the trailing ones after the clear button), and the search SHALL draw neither slot in the full-screen header. The hit areas of two neighbouring elements of the bar or the full-screen header SHALL stop at the middle of comp.search.container.gap, those of two neighbouring action buttons where the lengths SRC-34 keeps for them meet, and an icon-only Button's at the bar's edge. The gap, the length of SRC-34 and comp.search.container.padding-inline-with-button are what keep each icon-only Button's target whole: under the default system every icon-only Button of the bar and the header, the small clear button included, keeps a target at least sys.target.touch wide; a layer that narrows the gap or the padding narrows those targets.
SRC-26 WHILE disabled is true THE search SHALL NOT be focusable, editable or expandable, SHALL NOT emit input, submit, select or toggle, SHALL hide the clear button, SHALL expose the disabled state to assistive technology, and SHALL render the bar's container, outline, glyph, input, placeholder and opacity from the disabled component tokens; the slot icon-only Buttons keep their own state.
SRC-27 WHILE label is not empty THE search SHALL expose it as its accessible name, over a name the product gives it on the element (aria-label or aria-labelledby); WHILE label is empty and the product gives the search a name of its own on the element — aria-label, or aria-labelledby naming an element — THE search SHALL expose that name as its accessible name; WHILE label is empty and the product gives it none THE search SHALL still render, and in debug builds report that it has no accessible name; WHEN presentation, bar or status names a value the component does not define THE search SHALL render as docked, field or idle and in debug builds report the value; WHEN a result's headline is empty, or a result's or linked group heading's value is empty or repeats that of another suggestion, result or group, or a result group holds anything but results, THE search SHALL still render what it can and in debug builds report it; WHEN a suggestion's value is empty or repeats another's, or its headline is empty, THE search SHALL still render it and in debug builds report it; IF the trailing slot holds more than two elements THE search SHALL still lay them out and in debug builds report it.
SRC-28 WHILE the text size is enlarged THE search SHALL grow the bar and the full-screen header to hold one line of the input (their heights are minimums) and keep the value on one line, SHALL let suggestion rows grow and wrap, and SHALL NOT scale the icon-only Buttons it holds.
SRC-29 THE search SHALL hand the default slot's content comp.search.standard.suggestion.headline.color as the platform's inherited foreground (the web's inherited color, SwiftUI's foreground style, Compose's content color, Flutter's default text and icon style, React Native's Tanrei text context), inset by comp.search.suggestion.container.padding-inline.regular at the sides, and plain text given as that content, where the platform must style it, SHALL take sys.typescale.body.
SRC-30 IF the icon set cannot draw a glyph of the search yet (search, close or arrow_back; its font is still loading or failed to load) THE search SHALL draw nothing in that glyph's place, never the glyph's name as text, SHALL keep the glyph's box so that the bar's layout does not change, SHALL keep the clear and back buttons operable and named by clearLabel and backLabel, and SHALL draw the glyph once the icon set can.
SRC-31 THE search SHALL take its layout direction from where it is used — the direction of the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN that direction changes while the search is shown THE search SHALL draw itself for the new direction at once, without a motion of its own, keeping its value, whether it is expanded, and its focus.
SRC-32 WHERE the layout direction is right-to-left THE search SHALL draw a suggestion's leading icon and the arrow_back of its back button (SRC-11) mirrored left to right exactly when the system's icon set marks that glyph's name as mirrored or the product forces mirroring for that use, and unmirrored when the product forbids it: the icon helper mirrors the glyph inside its own box, about the box's vertical centre line, changing neither its place, size, color and fill nor the order SRC-1 and SRC-16 gives. THE search SHALL NOT mirror a glyph itself, and SHALL NOT mirror content the product gives as an image or a view of its own rather than by a glyph's name. The search glyph and the clear button's close are not marked and are never mirrored (SRC-2, SRC-10); the icon-only Buttons of the leading and trailing slots mirror their own glyphs (BTN-19).
SRC-33 THE search SHALL lay out its placeholder and a suggestion's headline and supporting text as text of its own direction, isolated from the text around it: each takes the base direction of its first strong character, or the layout direction where it has none, so that a left-to-right word, a number with its sign or unit, a telephone number and an address keep their own order in a right-to-left layout and reorder nothing beside them; THE search SHALL still place each and align its lines by the layout direction, not by the text's own.
SRC-34 THE search SHALL lay out the bar's action buttons — the clear button WHILE it is shown (SRC-10) and the icon-only Buttons of the trailing slot — comp.search.container.button-gap from one another, measured between their visible bounds, and SHALL move two of them further apart only as far as each needs in order to keep, centred on itself, a length of sys.target.touch along the row that its neighbour's does not reach into, because buttons that stand this close cannot extend a hit area over each other (as BGR-3): where the token is 0, as in the default system, a button at least sys.target.touch wide touches its neighbour, and a narrower one stands half of what it lacks away from it. The first action button SHALL still stand comp.search.container.gap after the input and the last comp.search.container.padding-inline-with-button from the bar's end edge (SRC-1). THE search SHALL NOT widen, resize or restyle a button to do so (SRC-25), and SHALL space the buttons the same whatever the input type, so that the bar does not change with the pointer.
SRC-35 WHILE bar is button THE search SHALL draw a trigger in place of the bar of SRC-1: one button as wide as its layout gives it and at least comp.search.trigger.container.height high, filled, raised and rounded as the bar is (comp.search.standard.container.color, comp.search.standard.container.elevation, comp.search.container.shape), holding in one row, vertically centered and comp.search.trigger.container.gap apart, the glyph search drawn as SRC-2 says at comp.search.trigger.leading-icon.size, comp.search.trigger.container.padding-inline from the start edge; then the placeholder — or the label WHILE placeholder is empty — on one line in comp.search.trigger.label.typescale and comp.search.standard.placeholder.color, taking the remaining width and cut at its own end where it does not fit (SRC-33); then the shortcut hint WHILE shortcut is not empty (SRC-37); the last of them ending comp.search.trigger.container.padding-inline from the end edge. WHILE bar is icon THE search SHALL draw in the bar's place one icon-only Tanrei Button of the text variant and the medium size showing the glyph search of the system's icon set, rendered from the Button's own tokens, and no hint. In either form THE search SHALL draw no input, no clear button and neither slot in the trigger, and SHALL NOT show the value while collapsed. Right-to-left layouts SHALL mirror the row.
SRC-36 WHILE bar is button or icon THE search SHALL treat its trigger as a button: WHEN it is activated by pointer, touch, Enter or Space THE search SHALL emit toggle once with expanded true and become expanded as SRC-5 says, presenting its view as a modal one — dialog WHILE presentation is dialog or docked, and full-screen WHILE it is full-screen — and in debug builds SHALL report presentation docked with a trigger, because a docked view has no input of its own. WHILE the button trigger is hovered, keyboard-focused or pressed THE search SHALL render its container, outline, outline width, glyph, text and opacity from the bar's component tokens of the highest-precedence state, with precedence pressed over focused over hovered, showing keyboard focus by the focused outline as the bar does (SRC-18); focus gained by pointer or touch SHALL NOT select the focused state, as for a Button; a press SHALL be answered as SRC-19 and SRC-20 say for the bar, and its hit area extended on both axes as SRC-22 says. THE search SHALL expose the trigger as a button named by label that opens a dialog, with whether its view is open (aria-haspopup with the value dialog and aria-expanded on the web), and with the search glyph hidden; WHILE disabled is true the trigger SHALL NOT be focusable or pressable, SHALL expose the disabled state and SHALL render from the disabled tokens (SRC-26).
SRC-37 WHILE shortcut is not empty THE search SHALL draw it with the keyboard shortcut component, hosted as KBS-13 says: in its plain form, at size small, with convention auto, disabled while the search is disabled, its legends and separators in comp.search.shortcut.typescale and comp.search.shortcut.color; it SHALL draw no cap, fill or edge (KBS-7), because the bar's fill may be the cap's own. It SHALL draw the hint at the end of a button trigger (SRC-35) and, WHILE bar is field, after the bar's input and comp.search.container.gap from it, only while the value is empty and the input does not have focus; it SHALL NOT draw it WHILE bar is icon, nor in a view's header. THE search SHALL expose the shortcut as the keyboard shortcut of its trigger, or of its input WHILE bar is field, in the platform's form (KBS-12: aria-keyshortcuts on the web), SHALL hide the drawn keys from assistive technology, and SHALL give the hint no press of its own: a press on it is a press on the trigger or the bar.
SRC-38 WHILE bindShortcut is true, shortcut holds exactly one chord and disabled is false, WHEN the person presses that chord anywhere in the window (read as KBS-1 reads it: mod is Command on Apple platforms and Control elsewhere) THE search SHALL, WHILE collapsed, open as an activation of its trigger does (SRC-36) or, WHILE bar is field, focus its input and expand (SRC-5), and WHILE expanded SHALL collapse with the reason shortcut (SRC-6); and it SHALL keep that press from doing anything else. THE search SHALL NOT act on a press that something else has already taken (a cancelled key event on the web), on a key repeating while held, during an input-method composition, or — for a chord without mod, ctrl or alt — while focus is in an element that takes text, its own input included, so that such a key types there. THE search SHALL listen only while it is part of what is shown (connected to the document, in the view tree) and SHALL stop when it is removed, disabled, or bindShortcut becomes false.
SRC-39 WHILE bindShortcut is false THE search SHALL NOT listen for any key outside itself: the hint and the exposed shortcut say what the product has bound, and the product opens the search by setting expanded. IF bindShortcut is true while shortcut is empty or holds more than one chord, or while another shown search binds the same chord, THE search SHALL bind nothing for itself — the search shown first keeps a chord two of them name — and in debug builds SHALL report it.
SRC-40 WHEN expanded becomes true WHILE presentation is dialog THE search SHALL present the view as a modal overlay on its modal layer (MDL-1, MDL-2, MDL-4): the layer's scrim in comp.search.view.scrim.color and comp.search.view.scrim.blur over the whole window, and above it a container centered between the window's side edges, its top comp.search.view.dialog.offset below the top of the safe area, as wide as the window allows up to comp.search.view.dialog.max-width while keeping comp.search.view.viewport-margin from each side edge, and as tall as its content up to the room left above comp.search.view.viewport-margin from the bottom of the safe area or from the on-screen keyboard; WHERE the window is too short to keep the offset and one row of content, it SHALL give up the offset down to comp.search.view.viewport-margin. It SHALL fill the container with comp.search.view.container.color, raise it by comp.search.view.container.elevation, round it by comp.search.view.container.shape and clip its content to that shape. At the container's top it SHALL draw a header at least comp.search.header.height high: the back button the full-screen view's header draws, drawn, mirrored, named by backLabel, reported and answered as SRC-11 says, comp.search.header.padding-inline from the start edge, where the full-screen header has it and in the search glyph's place, the input with the same value, and the clear button WHILE it is shown (SRC-10, at the medium size), comp.search.container.gap apart and vertically centered, the last ending comp.search.header.padding-inline from the end edge when it is the clear button and comp.search.container.padding-inline when it is the input; it SHALL draw no search glyph in the header. The back button SHALL be a stop of the view's focus order, so that a person can leave the view without Escape, a pointer or the scrim. WHILE the view has content under the header THE search SHALL draw a line of comp.search.divider.thickness in comp.search.divider.color across the container under it, then the content in the order SRC-46 gives, inset by comp.search.view.padding-block and comp.search.view.padding-inline and scrolling under the header when it is taller than the room. It SHALL move focus, keep it inside, make everything outside inert and hidden from assistive technology, and return focus when the view closes, all as SRC-9 says for the full-screen view; and it SHALL keep the container's top where it is while its content changes, so that the input does not move under the person's typing.
SRC-41 WHEN the dialog view opens THE search SHALL fade its scrim and its container in together (MDL-7, with the search's own motion, which its docked view shares) over comp.search.motion.open-duration with comp.search.motion.open-easing, and WHEN it closes SHALL fade both out over comp.search.motion.close-duration with comp.search.motion.close-easing, as SRC-23 says of the other views; WHEN the container's height changes with its content THE search SHALL draw the new height at once, without a motion of its own.
SRC-42 THE search SHALL lay out a result as a suggestion's row is laid out (SRC-16), from the same tokens: the leading icon column, then the headline in comp.search.suggestion.headline.typescale with the excerpt under it in comp.search.suggestion.supporting-text.typescale, both wrapping and growing the row rather than being cut, the row at least comp.search.suggestion.container.height.regular tall and at least the minimum target, and the whole row the result's hit area. The leading icon column SHALL be kept as SRC-52 says, the suggestions and the results of the view decided together, so that they align. WHILE a result is hovered, focused, current (SRC-49) or pressed THE search SHALL render its row from the suggestion tokens of that state (comp.search.standard.suggestion.container.color and the leading icon, headline and supporting-text colors, the excerpt taking the supporting-text color) with the precedence, the focus ring inside the row and the press answer that SRC-17, SRC-19 and SRC-20 give a suggestion, focused and current standing where active stands there.
SRC-43 THE search SHALL read an excerpt as runs of text in order, the second, fourth and every further even run being a match, SHALL draw the runs as one continuous text that wraps as one, and SHALL draw each match in comp.search.result.mark.color with its weight raised by comp.search.result.mark.emphasis, over a fill of comp.search.result.mark.container.color that covers the match's own line boxes, with square corners and no padding, so that the fill moves no text. A match SHALL be told from the excerpt around it by all three — color, weight and fill — because a match must not depend on color alone, and the reader's font, which the product does not choose, may have no weight between regular and bold, so that the raised weight draws as the regular one (an Arabic font often has none); the fill shows a match in every script, as the platform's own marked text is filled. A result is a destination, so what is marked in it is what matched; a query suggestion marks what it adds (SRC-56). THE search SHALL NOT look for the query in a result's text, mark a result's headline, or change, trim or shorten an excerpt: what matched and how long the passage is are the product's. It SHALL expose the excerpt to assistive technology as one text, the result's description, read without a pause or an announcement at a mark, and SHALL lay the whole excerpt out as text of its own direction (SRC-33).
SRC-44 THE search SHALL draw a result group as its heading followed by its results in order, comp.search.group.gap below whatever stands above it in the view and above whatever follows it. WHILE the group's href is empty its heading SHALL be the headline in comp.search.group-title.typescale and comp.search.group-title.color, wrapping, inset by comp.search.suggestion.container.padding-inline.regular at the sides and padded by comp.search.suggestion.container.padding-block.regular above and below, taking no input and no state. WHILE href is not empty the heading SHALL be a result's row (SRC-42, SRC-45) made of the group's headline, excerpt and leading icon, and the group's results SHALL be inset at the start by comp.search.group.indent, their hit areas and highlights with them, so that they read as parts of it. A group SHALL hold results only, and SHALL NOT hold a group. Right-to-left layouts SHALL mirror the inset.
SRC-45 THE search SHALL make each result, and each group heading, whose href is not empty a link and not an option or a button: the platform's own link to href (the web's anchor element; elsewhere an element with the platform's link semantics whose address the platform's opener opens), so that whatever the platform gives a link — on the web following it by Enter or a press, opening it in a new tab by a modifier key or the middle button, its context menu, dragging and copying its address, the address shown before it is followed — is the platform's and not the search's to imitate; it SHALL activate a link by pointer, touch or Enter and not by Space, SHALL open it in a new context WHILE target is new (on the web one that is given no handle to the page that opened it) and expose targetLabel as its description after the excerpt, and SHALL draw no mark of its own for a new context. WHEN a result is activated in place (by Enter, touch or a primary press, without a modifier key, target being same) THE search SHALL emit select once with the result's value and then let the platform open href, unless the product cancelled that select, in which case it SHALL open nothing because the product's router has taken it; and SHALL then collapse with the reason select (SRC-6), so that toggle follows select. WHEN a result is opened any other way (a modifier key, the middle button, the context menu, target new) THE search SHALL emit nothing and stay expanded, so that a person can open several results from one search. WHILE a result's href is empty, or names a script rather than a place, it SHALL be a button, activated by pointer, touch, Enter or Space, for which select is all that happens.
SRC-46 WHILE expanded THE search SHALL lay out the content of its view from top to bottom in this order: the suggestions, the status row (SRC-47), the results and result groups in the order the product gives them, and the default slot's content; a part that is absent takes no room.
SRC-47 WHILE statusText is not empty or status is loading THE search SHALL draw a status row: inset by comp.search.suggestion.container.padding-inline.regular at the sides and padded by comp.search.suggestion.container.padding-block.regular above and below, taking no input and no state. WHILE status is idle it SHALL draw statusText, wrapping, in comp.search.status.typescale and comp.search.status.color; WHILE status is error it SHALL draw it in comp.search.status.error.color; WHILE status is loading it SHALL draw, in the text's place and at the row's start, one Tanrei loading indicator of size small named by statusText, which waits its own show delay and enters as the loading indicator does (LDG-11 to LDG-14), and no text, and the row SHALL keep the height of one line of text whether or not the indicator is shown yet. The results the product leaves in the view WHILE status is loading SHALL stay drawn and usable.
SRC-48 THE search SHALL expose the status row as a live region that is present from the moment the view opens: WHILE status is idle, WHEN statusText changes THE search SHALL have assistive technology read the new text politely, after what it is saying (the status role on the web); WHILE status is error it SHALL have it read at once (the alert role); WHILE status is loading it SHALL announce nothing — the loading indicator does not announce itself (LDG-6) — and SHALL mark the results as busy (aria-busy on the web) until status leaves loading. THE search SHALL NOT compose, count or translate the text: the number of results and the words around it are the product's.
SRC-49 WHILE expanded, the input has focus and the view holds a result and no suggestion THE search SHALL make the first result current automatically, focus staying in the input, as SRC-14 makes its first place current and, as there, not WHILE the person types on an on-screen keyboard or an input method is composing: WHEN the view comes to show results — it opens with them, the product gives or replaces them, or focus comes back to the input — and WHEN the person types, deletes or pastes. It SHALL draw the current result as a focused one (SRC-42), and the action key in the input SHALL activate it as Enter on it does (SRC-45), so that one press of Enter goes to what the search found first, as a documentation search does. With the modifier that opens a link elsewhere — Command under the Apple keyboard convention and Control under the others for a new tab, Shift for a new window — the action key in the input SHALL open the current result's destination there, as that press on the link does: nothing emitted and the view kept open (SRC-45); a current result without a destination takes no such press. WHILE the input does not have focus no result SHALL be current. The results SHALL be the last rows of the arrow keys' cycle (SRC-14), in view order, across groups, a linked group heading counting as a result and a title not, and an arrow key that reaches a result SHALL move focus to it: WHEN the person presses Down Arrow in the input while the first result is current THE search SHALL move focus to the second result, and to the first WHILE no result is current and there is no suggestion to go to (none in the view, or the last one active). WHILE a result has focus THE search SHALL move focus to the next result with Down Arrow and to the previous one with Up Arrow; Up Arrow on the first SHALL go back to the input with the last suggestion active, where the view holds suggestions; and at the ends of the cycle, WHILE wrap is true, Down Arrow on the last result SHALL go to the first place of the cycle — focus going back to the input, to the query row or the input's place, or, with no suggestion, to the first result — and, with no suggestion in the view, Up Arrow on the first result, whether it has focus or is current in the input, SHALL move focus to the last result; WHILE wrap is false they SHALL do nothing there. WHEN a result takes focus or becomes current while part of it is scrolled out of view THE search SHALL scroll it into view, and SHALL show the focus ring inside its row (SRC-42). WHILE a result has focus, WHEN the person types a character, deletes or pastes THE search SHALL move focus to the input so that the key edits the value there, and Escape SHALL close the view as from the input (SRC-6). Tab and Shift+Tab SHALL move through the results as through any links WHILE the view is modal, and SHALL leave the search and close the view WHILE it is docked (SRC-6). A pointer over a result SHALL NOT move focus, and the arrows SHALL NOT reach the status row or the default slot's content.
SRC-50 THE search SHALL expose its results as links in a list, outside the suggestions' listbox: one list named by label holding the results in order, each result a link named by its headline and described by its excerpt, with its position in the list where the platform gives one; a result group as a group named by its headline holding its own list of its results, and a linked heading as a link before that list; a result without href as a button in the same place. A result SHALL never carry the option role: an option cannot be a link, and a result must be one. The result current while focus stays in the input (SRC-49) SHALL be announced as the query row is (SRC-24) — on the web the input names the result's link as its active descendant once it has stayed current for 500 milliseconds with nothing typed —, the input staying a search box; what the search found is also said by the status row (SRC-48), and the result takes real focus as soon as the person moves to it. On the platforms without a link element THE search SHALL expose a result as a button with the link trait or role where the platform has one, named and described the same way. Leading icons SHALL be hidden, and the status row is exposed as SRC-48 says.
SRC-51 THE search SHALL NOT run a query, fetch, wait, debounce, cache, sort or filter anything itself: it emits input once per change (SRC-4) and draws the suggestions, the results, the status and the statusText the product gives it, replacing them when the product does, at once and without a motion of its own. WHEN the result that has focus is removed or replaced, or the product replaces its content whole so that the element that held the focus goes with it, THE search SHALL move focus to the input rather than let it fall out of the view; WHEN the product sets results or status while the view is collapsed THE search SHALL keep them for the next time it opens and SHALL NOT expand.
SRC-52 THE search SHALL decide the leading icon column for its view as a whole — its suggestions, its query row, its results and the linked headings of its result groups (SRC-16, SRC-42, SRC-44, SRC-57) — as iconSpace says. WHILE iconSpace is auto every row SHALL keep the column, empty where it has no icon, WHERE any suggestion or result of the view has a leading icon — the query row, drawn with the search glyph, counting as one that has —, so that the headlines of the view start on one line, and no row SHALL keep it WHERE none has one; WHILE iconSpace is always every row SHALL keep it, whether or not any has an icon; WHILE iconSpace is never a row SHALL have the column only where it has a leading icon itself. The column kept is comp.search.suggestion.leading-icon.size.regular wide with comp.search.suggestion.container.gap.regular after it, draws nothing and is nothing to assistive technology. WHEN a suggestion or a result is added or removed, or its leadingIcon changes, or the query row is drawn or taken away, THE search SHALL decide again; WHEN iconSpace names a value the search does not define THE search SHALL treat it as auto and in debug builds report the unknown value.
SRC-53 THE search SHALL draw every row of its view — a suggestion, a result, a result group's linked heading — at its density. WHILE density is regular a row SHALL take the regular value of every token of the density axis this spec names (comp.search.suggestion.container.height.regular, comp.search.suggestion.container.padding-block.regular, comp.search.suggestion.container.padding-inline.regular, comp.search.suggestion.container.gap.regular, comp.search.suggestion.leading-icon.size.regular); WHILE density is compact it SHALL take the compact value of each in its place (comp.search.suggestion.container.height.compact, comp.search.suggestion.container.padding-block.compact, comp.search.suggestion.container.padding-inline.compact, comp.search.suggestion.container.gap.compact, comp.search.suggestion.leading-icon.size.compact), so that a compact row is lower, set in less from its edges and draws a smaller glyph, the room kept for an empty leading icon column (SRC-52) shrinking with it. The text styles, the group titles, the status row, the view's surface, its header and the bar SHALL be the same in both. WHEN density names a value the active design system does not have THE search SHALL draw the default density's rows and in debug builds report the unknown value; a density a design system added SHALL be drawn from that density's tokens, as the core values are. WHEN density changes while the view is shown THE search SHALL draw the new rows at once, without a motion, keeping the active row.
SRC-54 WHERE the platform has ARIA attributes (the web), WHEN the product sets an aria- attribute on the host, by the attribute or by the ARIA property that reflects it, THE search SHALL move it to the data-aria- attribute of the same name, so that the host is no second node with its name, description or state, and SHALL expose it on the element that carries its role — an id reference by the elements it names in the host's tree or a tree around it, an error message as part of the description while the search is invalid — except those the search owns (aria-haspopup, aria-expanded, aria-controls, aria-keyshortcuts, aria-disabled), which it SHALL move and not expose. WHEN the product removes the aria- attribute or its data-aria- twin, or sets the ARIA property that reflects it (ariaLabel, ariaDescribedByElements…) to null, THE search SHALL take it off that element. WHEN the product sets an aria- attribute the search owns THE search SHALL report it in debug builds.
SRC-55 WHILE inlineCompletion is true and the query row is drawn (SRC-57), WHEN the person inserts text at the end of the value — by typing, or as an input method commits its composition — or the product gives or replaces the suggestions after such an insertion, THE search SHALL complete the value in the input from the first suggestion, in the product's order, whose headline begins with the value and is longer than it, compared as the combobox compares a label with what was typed (CMB-25): it SHALL write the rest of that headline after the value, selected, with the caret before it, without changing value or emitting input, and the query row SHALL show the completed text and stay active. THE search SHALL NOT complete after the person deleted (Backspace, Delete, a cut) or pasted, until they insert text again; WHILE an input method is composing; WHILE the person types on an on-screen keyboard (SRC-14); WHILE the caret is not at the end of the value or the person has selected text; or WHERE no suggestion's headline begins with the value. WHEN the person moves the caret or the selection — an arrow key, Home, End, a press in the input — THE search SHALL accept the completion: the completed text SHALL become the value, input SHALL be emitted once, and the caret SHALL move as the key or the press moves it. WHEN the person presses Backspace or Delete while a completion is shown THE search SHALL take the completion away and nothing else: the value stays as typed, no input is emitted, and nothing is completed again until the person inserts text. Typing a character SHALL replace the completion and go on from the value as typed, which may be completed again; WHEN an input method begins to compose while a completion is shown, its first inserted text SHALL replace the completion as a typed character does, and WHEN the composition is cancelled before it inserted anything THE search SHALL take the completion away as Backspace does: the value stays as typed and no input is emitted. The action key SHALL accept the completion and then submit (SRC-13). WHEN an arrow key makes a suggestion active the input SHALL show that suggestion (SRC-14), and WHEN the query row becomes current again THE search SHALL show the completion again as it was. WHEN the view closes or the input loses focus THE search SHALL take an unaccepted completion away. WHILE inlineCompletion is false or queryRow is none THE search SHALL complete nothing.
SRC-56 WHILE the value is not empty THE search SHALL draw, in the headline of each suggestion that begins with the value — compared as SRC-55 compares —, the rest of the headline, its completion, with its weight raised by comp.search.suggestion.completion.emphasis over the weight of comp.search.suggestion.headline.typescale, in the headline's own color and with no fill, as a web search draws what each suggestion would add to what was typed: the person knows what they typed, and tells the suggestions apart by what each adds. A headline that does not begin with the value SHALL be drawn without emphasis; the query row's headline is the value itself, and only an inline completion shown after it is emphasised (SRC-57, SRC-55). The completion SHALL wrap with the headline as one text, move no letter of it, and be read as part of the headline, without a pause or an announcement. THE search SHALL NOT emphasise anything in a suggestion's supporting text, and the excerpt of a result marks what matched instead (SRC-43).
SRC-57 WHILE queryRow is first, the view shows suggestions and the value is not empty THE search SHALL draw a query row above the first suggestion: a suggestion's row (SRC-16, SRC-17, SRC-19, SRC-20, SRC-53), drawn from the suggestion tokens, holding in its leading icon column the glyph search of the system's icon set, drawn as a suggestion's leading icon and never mirrored (SRC-2), the value as typed as its headline — followed by the inline completion WHILE one is shown, emphasised as SRC-56 says —, and queryRowText as its supporting text WHILE queryRowText is not empty. It is the search's own row and holds no word of the search's own: what it says beside the query is the product's, and the glyph and the query alone are a whole row. It SHALL be the row the search makes active automatically (SRC-14), so that the action key always searches for the value as typed (SRC-13), as the first row of a browser's address bar does; WHEN the person presses it by pointer or touch, or presses the action key while it is active, THE search SHALL submit as SRC-13 says, focus staying in the input, and SHALL NOT emit select. It is never a query of its own to fill the input with: WHEN it becomes current again the input shows the value as typed (SRC-14). THE search SHALL expose it as the first option of the suggestions' listbox, named by its headline and described by queryRowText, counted in the options' positions. WHILE queryRow is none THE search SHALL draw no query row; WHEN queryRow names a value the search does not define THE search SHALL draw the query row as for first and in debug builds report the value.

Platform name mapping

Parity does not mean identical APIs. Each platform uses its own idiom for the same contract.

Spec Web SwiftUI Jetpack Compose Flutter React Native
Component tanrei-search TanreiSearch TanreiSearch TanreiSearch Search
presentation · Property presentation presentation presentation presentation presentation
bar · Property bar bar bar bar bar
value · Property value text value controller value
label · Property label label label semanticLabel accessibilityLabel
placeholder · Property placeholder prompt placeholder hintText placeholder
expanded · Property expanded isExpanded expanded controller expanded
disabled · Property disabled disabled enabled enabled disabled
clearLabel · Property clearLabel clearLabel clearLabel clearLabel clearLabel
backLabel · Property backLabel backLabel backLabel backLabel backLabel
shortcut · Property shortcut shortcut shortcut shortcut shortcut
bindShortcut · Property bindShortcut bindsShortcut bindShortcut bindShortcut bindShortcut
status · Property status status status status status
statusText · Property statusText statusText statusText statusText statusText
queryRow · Property queryRow queryRow queryRow queryRow queryRow
queryRowText · Property queryRowText queryRowText queryRowText queryRowText queryRowText
inlineCompletion · Property inlineCompletion inlineCompletion inlineCompletion inlineCompletion inlineCompletion
wrap · Property wrap wrap wrap wrap wrap
iconSpace · Property iconSpace iconSpace iconSpace iconSpace iconSpace
density · Property density density density density density
input · Event input text onValueChange onChanged onChangeText
submit · Event submit onSubmit onSearch onSubmitted onSubmitEditing
select · Event select onSelect onSelect onSelected onSelect
toggle · Event toggle isExpanded onExpandedChange onExpandedChanged onExpandedChange
Notes A form-associated custom element, as the text field is: it takes name and submits its value. It renders an <input type="search" enterkeyhint="search"> in its shadow root, with the web's own cancel button hidden. Attributes are kebab-case (clear-label, back-label, query-row, query-row-text, inline-completion); wrap defaults to true, so its attribute is the inverse, no-wrap, as a boolean attribute cannot default to true. The suggestions are <tanrei-search-suggestion> children; the leading and trailing slots are named slots, and other children are the view's default content. The docked view is a manual popover in the top layer, placed with CSS anchor positioning and a script fallback, with the search's own light dismiss so that toggle carries a reason; a press outside also reaches the element under it. The full-screen view is a <dialog> opened with showModal(). The element sets its own expanded before firing toggle, which is a CustomEvent whose detail holds expanded and reason; submit is cancelable. The inline attribute, for tests, draws the open view in place. The leading glyph is the icon helper's search; the clear and back buttons show close and arrow_back (SRC-2, SRC-10, SRC-11). Not built yet: bar="button" and bar="icon" render a <button> (the icon form a <tanrei-button icon-only>) with aria-haspopup="dialog", aria-expanded and aria-keyshortcuts; the dialog view is a <dialog> opened with showModal(), its scrim the ::backdrop, a press on which closes it with the reason outside; shortcut is an attribute of chords separated by spaces, as the keyboard shortcut's keys; bind-shortcut adds one keydown listener on the window while the element is connected. The status row is a role="status" element that exists from the first render (role="alert" while status="error"). Results are <tanrei-search-result> and <tanrei-search-result-group> children; focus moves to their anchors with focus(), and select on a result is cancelable. The query row is an option of the search's own in its shadow root, first in the listbox (id="query-row"). A suggestion an arrow key reaches is written into the input element without setting value or firing input; the element is written back from value when the person returns. The inline completion is a selection range after the typed text; the input a Backspace fires to take it away, which changes no value, is stopped in the shadow root. An automatic row is named by aria-activedescendant 500 ms after it became current, from a timer each edit restarts and clears. A result's link is its own light-DOM child (the <a>, or the <button> without href), slotted over the row the result draws in its shadow root and drawn as nothing itself, so that the input reaches it as its active descendant by element reflection (ariaActiveDescendantElement): an id cannot cross a shadow root, and reflection reaches out into the document, never into another shadow root. An on-screen keyboard (SRC-14) is told by the pointerType of the press that focused the input — touch or pen — and a hardware keyboard by its arrow and caret keys; (pointer: coarse) describes only the primary pointer, and the VirtualKeyboard API is Chromium's alone. TanreiSearch(_ label:, text: Binding<String>, isExpanded: Binding<Bool>, presentation:, prompt:, clearLabel:, backLabel:, onSubmit:, onSelect:) { suggestions } leading: { … } trailing: { … } content: { … }. Every edit writes the text binding, which is the input event; opening and closing write isExpanded, which is toggle (the reason is passed to an optional onToggle). SwiftUI's .searchable is not used: its field and suggestions cannot take the tokens. The docked view is drawn in an overlay above the window's content, anchored to the bar, not with .popover, which is modal at compact widths and would take focus from the field (SRC-8). The full-screen view is presented with .fullScreenCover, with the system transition off, as the dialog is. The input has the search-field trait. disabled follows .disabled(_:). Snapshot harness: renders the bar and the open view in place, as the menu and the dialog do. Without an installed icon font it strokes the search and back glyphs as shapes of its own (TanreiSearchMagnifierShape, TanreiSearchBackArrowShape) instead of drawing nothing (SRC-2, SRC-30). Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut (where bindsShortcut would be .keyboardShortcut on the trigger), status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds. Compose idiom, as Material's SearchBar with its input field: TanreiSearch(value, onValueChange, expanded, onExpandedChange, label, modifier, presentation, placeholder, enabled, clearLabel, backLabel, onSearch, onSelect, leading, trailing) { suggestions and content }. State hoisting: the caller keeps value and expanded and moves them from onValueChange and onExpandedChange, which receives the new value and the reason. enabled is the inverse flag. Built on BasicTextField with the search IME action. The docked view is a Popup that does not take focus; the full-screen view is a Dialog window with usePlatformDefaultWidth = false and the window's own dim off, as the dialog's. Compose has no combobox or listbox role: the suggestions are buttons in a column with collection semantics. Snapshot harness: renders the bar and the open view in place. Without an installed icon font it strokes the clear button's close as a vector of its own (TanreiDrawnGlyph), and draws search and arrow_back as their names in the platform font, clipped to the box (TanreiNamedGlyph), instead of drawing nothing (SRC-2, SRC-30). Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut, bindShortcut (a key handler on the window's root, where a hardware keyboard exists), status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds. Flutter idiom, as Material's SearchAnchor and SearchController but without Material: TanreiSearch(controller: TanreiSearchController, semanticLabel:, presentation:, hintText:, enabled:, clearLabel:, backLabel:, onChanged:, onSubmitted:, onSelected:, onExpandedChanged:, leading:, trailing: [...], suggestions: [...], child:). TanreiSearchController is a TextEditingController that also holds isExpanded with expand() and collapse(); the search updates it itself and calls onExpandedChanged with the value and the reason. The input is EditableText with TextInputAction.search and SemanticsInputType.search (Flutter 3.32, the oldest version supported, asserts on SemanticsRole.searchBox). The docked view is drawn through an OverlayPortal; the full-screen view is a modal route that scopes semantics, as the dialog's. Snapshot harness: a golden of the bar and the open view. Lagging behind SRC-30: it writes the built-in glyphs as Material Symbols code points (tanreiSearchGlyph, tanreiCloseGlyph, tanreiArrowBackGlyph), and without the icon font it draws whatever the fallback face has at those code points instead of nothing. Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut, bindShortcut (a HardwareKeyboard handler), status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds. Controlled, in TextInput's idiom: <Search value onChangeText expanded onExpandedChange accessibilityLabel placeholder presentation clearLabel backLabel onSubmitEditing onSelect suggestions={[…]} leading trailing insets>{content}</Search>; the caller moves value and expanded from onChangeText and onExpandedChange, which receives the new value and the reason. The input is a TextInput with returnKeyType="search" and accessibilityRole="search". The docked view is on the overlay layer that TanreiProvider renders, not a Modal (which would take focus from the field); the full-screen view is a transparent Modal with statusBarTranslucent and navigationBarTranslucent, its insets from the insets prop or TanreiProvider's. Android's back button (BackHandler) closes the view. Snapshot harness: renders the bar and the open view in place. Lagging behind SRC-30: without the icon font the built-in glyphs print their ligature names. Not built on this platform yet: queryRow, queryRowText, inlineCompletion and wrap (it draws no query row, completes nothing and stops the arrow keys at the ends), bar, the dialog presentation, shortcut, status, statusText, iconSpace (SRC-52: it keeps the leading icon column in every row while any suggestion has an icon) and the result kinds; bindShortcut does nothing where there is no hardware keyboard event to listen to, and the README says so.

Tokens

Token Aliases Resolved (light)
--tanrei-comp-search-container-button-gap sys.space.space0 0px
--tanrei-comp-search-container-gap — 16px
--tanrei-comp-search-container-height — 56px
--tanrei-comp-search-container-padding-inline sys.space.space200 16px
--tanrei-comp-search-container-padding-inline-with-button sys.space.space100 8px
--tanrei-comp-search-container-shape sys.shape.corner.full 9999px
--tanrei-comp-search-disabled-opacity — 1
--tanrei-comp-search-disabled-outline-width — 1px
--tanrei-comp-search-divider-color sys.color.outline-variant #000000 · 8%
--tanrei-comp-search-divider-thickness sys.border.hairline 1px
--tanrei-comp-search-focused-opacity — 1
--tanrei-comp-search-focused-outline-width — 2px
--tanrei-comp-search-group-title-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-group-gap sys.space.space100 8px
--tanrei-comp-search-group-indent sys.space.space300 24px
--tanrei-comp-search-header-height — 72px
--tanrei-comp-search-header-padding-inline sys.space.space100 8px
--tanrei-comp-search-hovered-opacity — 1
--tanrei-comp-search-hovered-outline-width — 1px
--tanrei-comp-search-leading-icon-size sys.icon.medium 24px
--tanrei-comp-search-motion-close-duration sys.motion.role.appear.anchored.exit 250ms
--tanrei-comp-search-motion-close-easing sys.motion.easing.exit cubic-bezier(0.3, 0, 1, 1)
--tanrei-comp-search-motion-feedback-duration sys.motion.role.feedback 450ms
--tanrei-comp-search-motion-open-duration sys.motion.role.appear.anchored.enter 300ms
--tanrei-comp-search-motion-open-easing sys.motion.easing.enter cubic-bezier(0.2, 0, 0, 1)
--tanrei-comp-search-motion-state-duration sys.motion.role.state.default 250ms
--tanrei-comp-search-motion-state-easing sys.motion.easing.state cubic-bezier(0.2, 0, 0, 1)
--tanrei-comp-search-outline-width sys.border.hairline 1px
--tanrei-comp-search-pressed-opacity — 1
--tanrei-comp-search-pressed-outline-width — 1px
--tanrei-comp-search-result-mark-color sys.color.on-surface #1b1b1b
--tanrei-comp-search-result-mark-container-color sys.color.secondary-container #eeeeee
--tanrei-comp-search-result-mark-emphasis sys.typescale.emphasis.body 100
--tanrei-comp-search-shortcut-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-caret-color sys.color.primary #1b1b1b
--tanrei-comp-search-standard-container-color sys.color.surface-container-highest #eeeeee
--tanrei-comp-search-standard-container-elevation sys.elevation.level0
--tanrei-comp-search-standard-disabled-caret-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-container-color — #eeeeee
--tanrei-comp-search-standard-disabled-container-elevation —
--tanrei-comp-search-standard-disabled-input-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-leading-icon-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-outline-color — #000000 · 0%
--tanrei-comp-search-standard-disabled-placeholder-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-state-layer-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-container-color — #000000 · 0%
--tanrei-comp-search-standard-disabled-suggestion-headline-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-leading-icon-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-state-layer-color — #1b1b1b · 38%
--tanrei-comp-search-standard-disabled-suggestion-supporting-text-color — #1b1b1b · 38%
--tanrei-comp-search-standard-focused-caret-color — #1b1b1b
--tanrei-comp-search-standard-focused-container-color — #eeeeee
--tanrei-comp-search-standard-focused-container-elevation —
--tanrei-comp-search-standard-focused-input-color — #1b1b1b
--tanrei-comp-search-standard-focused-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-focused-outline-color — #0070ac
--tanrei-comp-search-standard-focused-placeholder-color — #4b4b4b
--tanrei-comp-search-standard-focused-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-focused-suggestion-container-color — #1b1b1b · 10%
--tanrei-comp-search-standard-focused-suggestion-headline-color — #1b1b1b
--tanrei-comp-search-standard-focused-suggestion-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-focused-suggestion-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-focused-suggestion-supporting-text-color — #4b4b4b
--tanrei-comp-search-standard-hovered-caret-color — #1b1b1b
--tanrei-comp-search-standard-hovered-container-color — #dddddd
--tanrei-comp-search-standard-hovered-container-elevation —
--tanrei-comp-search-standard-hovered-input-color — #1b1b1b
--tanrei-comp-search-standard-hovered-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-hovered-outline-color — #000000 · 0%
--tanrei-comp-search-standard-hovered-placeholder-color — #4b4b4b
--tanrei-comp-search-standard-hovered-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-hovered-suggestion-container-color — #1b1b1b · 8%
--tanrei-comp-search-standard-hovered-suggestion-headline-color — #1b1b1b
--tanrei-comp-search-standard-hovered-suggestion-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-hovered-suggestion-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-hovered-suggestion-supporting-text-color — #4b4b4b
--tanrei-comp-search-standard-input-color sys.color.on-surface #1b1b1b
--tanrei-comp-search-standard-leading-icon-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-outline-color — #000000 · 0%
--tanrei-comp-search-standard-placeholder-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-pressed-caret-color — #1b1b1b
--tanrei-comp-search-standard-pressed-container-color — #d9d9d9
--tanrei-comp-search-standard-pressed-container-elevation —
--tanrei-comp-search-standard-pressed-input-color — #1b1b1b
--tanrei-comp-search-standard-pressed-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-pressed-outline-color — #000000 · 0%
--tanrei-comp-search-standard-pressed-placeholder-color — #4b4b4b
--tanrei-comp-search-standard-pressed-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-pressed-suggestion-container-color — #1b1b1b · 10%
--tanrei-comp-search-standard-pressed-suggestion-headline-color — #1b1b1b
--tanrei-comp-search-standard-pressed-suggestion-leading-icon-color — #4b4b4b
--tanrei-comp-search-standard-pressed-suggestion-state-layer-color — #1b1b1b
--tanrei-comp-search-standard-pressed-suggestion-supporting-text-color — #4b4b4b
--tanrei-comp-search-standard-state-layer-color comp.search.standard.input.color #1b1b1b
--tanrei-comp-search-standard-suggestion-container-color — #000000 · 0%
--tanrei-comp-search-standard-suggestion-headline-color sys.color.on-surface #1b1b1b
--tanrei-comp-search-standard-suggestion-leading-icon-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-standard-suggestion-state-layer-color comp.search.standard.suggestion.headline.color #1b1b1b
--tanrei-comp-search-standard-suggestion-supporting-text-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-status-color sys.color.on-surface-variant #4b4b4b
--tanrei-comp-search-status-error-color sys.color.error #cd262f
--tanrei-comp-search-suggestion-completion-emphasis — 300
--tanrei-comp-search-suggestion-container-gap-compact comp.tree-view.container.gap.compact 8px
--tanrei-comp-search-suggestion-container-gap-regular sys.space.space200 16px
--tanrei-comp-search-suggestion-container-height-compact comp.tree-view.container.height.compact 32px
--tanrei-comp-search-suggestion-container-height-regular — 56px
--tanrei-comp-search-suggestion-container-padding-block-compact — 4px
--tanrei-comp-search-suggestion-container-padding-block-regular — 8px
--tanrei-comp-search-suggestion-container-padding-inline-compact comp.tree-view.container.padding-inline.compact 8px
--tanrei-comp-search-suggestion-container-padding-inline-regular sys.space.space200 16px
--tanrei-comp-search-suggestion-container-shape — 4px
--tanrei-comp-search-suggestion-leading-icon-size-compact sys.icon.small 20px
--tanrei-comp-search-suggestion-leading-icon-size-regular sys.icon.medium 24px
--tanrei-comp-search-trigger-container-gap sys.space.space100 8px
--tanrei-comp-search-trigger-container-height — 40px
--tanrei-comp-search-trigger-container-padding-inline sys.space.space150 12px
--tanrei-comp-search-trigger-leading-icon-size sys.icon.small 20px
--tanrei-comp-search-view-container-color sys.color.surface-bright #ffffff
--tanrei-comp-search-view-container-elevation sys.elevation.level2 0px 0px 0px 1px rgb(0 0 0 / 0.08), 0px 1px 2px 0px rgb(0 0 0 / 0.04)
--tanrei-comp-search-view-container-shape sys.shape.corner.medium 8px
--tanrei-comp-search-view-dialog-max-width — 640px
--tanrei-comp-search-view-dialog-offset sys.space.space800 64px
--tanrei-comp-search-view-offset sys.space.space50 4px
--tanrei-comp-search-view-padding-block sys.space.space50 4px
--tanrei-comp-search-view-padding-inline sys.space.space50 4px
--tanrei-comp-search-view-scrim-blur comp.modal-layer.scrim.blur 0px
--tanrei-comp-search-view-scrim-color comp.modal-layer.scrim.color #000000 · 40%
--tanrei-comp-search-view-viewport-margin sys.space.space100 8px
--tanrei-comp-search-group-title-typescale sys.typescale.label-small 500 12px/1.3333
--tanrei-comp-search-input-typescale sys.typescale.body-large 400 16px/1.625
--tanrei-comp-search-shortcut-typescale sys.typescale.label-small 500 12px/1.3333
--tanrei-comp-search-status-typescale sys.typescale.body-small 400 13px/1.5385
--tanrei-comp-search-suggestion-headline-typescale sys.typescale.body 400 14px/1.5714
--tanrei-comp-search-suggestion-supporting-text-typescale sys.typescale.body-small 400 13px/1.5385
--tanrei-comp-search-trigger-label-typescale sys.typescale.body 400 14px/1.5714

Fixtures

Canonical renderings. Every platform snapshots each fixture under the same id so the results can be compared.

Generated from specs/search.spec.json, tokens/comp/search.tokens.json, design/tokens/

Guidelines

When to use

Use the search when searching is a main way into the product’s content, such as mail, files, contacts or settings, and suggestions help people get there faster. Put it at the top of the screen or of the page it searches.

Use it as a site search too: a trigger in the header that opens a dialog, with the pages and sections found as links.

To filter a short list that is already on screen, or to enter a search term in a form, a text field with type search is enough. Choosing one value from a fixed list is a job for a menu or a list, not a search.

The bar or a trigger

bar What stands in the page Opens Use for
field (default) The bar with its input Any presentation A product where search is a main way in, and the bar has a place of its own
button A trigger shaped like the bar: the glyph, the placeholder and the shortcut hint A modal view: the dialog or full-screen A header with room, where search is one of several things
icon An icon-only button with the search glyph A modal view: the dialog or full-screen A header without room, such as a narrow window

A trigger is named by label, and a button trigger shows the placeholder, or the label where there is none. When its view closes, focus returns to the trigger.

Docked, dialog or full-screen

Presentation Where the view opens Focus Use for
Docked (default) Under the bar, as wide as it, over the content Stays in the bar’s input. Nothing else becomes inert, and there is no scrim Large windows, where the view can open without hiding the whole screen
Dialog Near the top of the window, centred, up to a maximum width, over a scrim. Its top stays put while its content changes Moves to the header’s input, stays in the view, and comes back to the trigger or the bar when it closes Large windows, opened from a trigger: a site search
Full-screen Over the whole window, with its own header, back button and divider Moves to the header’s input, stays in the view, and comes back to the bar or the trigger when it closes Small windows, where suggestions and the on-screen keyboard leave no room for anything else

The query is the same in all three. Switching presentation at a breakpoint does not change it.

The clear and back buttons

Both are built in, because their behaviour belongs to the search: clear empties the query and keeps the view and focus where they are, and back closes the full-screen view. Their names must be in your product’s language, so you give them: clearLabel (“Clear search”) and, for the dialog and full-screen, backLabel (“Back”). On iOS the back button is the only way out of the full-screen view. The dialog’s header has the back button too, so a person with neither Escape nor a pointer can leave it.

Suggestions, results and your content

  • A suggestion is a query; a result is somewhere to go. A suggestion helps finish the query, and the arrow keys make it active while focus stays in the input. A result is a thing your search found: a link that takes focus itself.
  • Don’t add the query as typed to your suggestions: the query row is it. Give queryRowText where the row should say what Enter does (“Search all mail”, “Ask the assistant”), in your product’s language.
  • Choose the form by what the search is. Keep the query row (the default) where Enter should always search for what was typed, as in an address bar or a mail search. Use queryRow="none" for a search page whose suggestions sit under the field, as on a web search page. A search whose rows are only results, such as a documentation search, needs neither: its first result is the one Enter opens.
  • Use inlineCompletion only where people type known things to the end, such as addresses or names, and a completion saves them keys. Search pages do not complete in the field.
  • Use the leading icon to tell kinds apart: history for a past query, a folder, a page, a section.
  • Where only some rows have an icon, iconSpace decides where the others start their headline. auto (the default) keeps the icon’s room, empty, in every row of the view while any suggestion or result has an icon, so that the headlines line up; always keeps it in every row, and never only in a row that has an icon. The menu has the same iconSpace, with the same values and default.
  • density sets how much room a row of the view takes: regular (the default, 56 high) or compact (32 high with a 20 glyph), for a command palette or a tool used with a mouse and the keyboard. Neither the bar nor the text changes. For touch a row is never lower than the touch target.
  • Keep headlines short and put detail in the supporting text or the excerpt: “Invoices”, then “Folder · 24 messages”. They wrap rather than being cut off.
  • Mark in the excerpt what matched. The mark is the system’s, a color, a heavier weight and a quiet fill behind the match, so matches look the same everywhere and are found in every script, also where the font has no weight between regular and bold.
  • Group results when they belong together: sections under their page, messages under “Messages”. A group’s heading is a link when the group itself is a place.
  • Give a result an href whenever it has an address. A person can then open it in a new tab, copy its address and see where it leads. Use select without an href only for a result your product opens itself.
  • The view’s order is fixed: suggestions, the status row, results, then your own content, such as a “Load more results” button or a link to a full results page.
  • A docked view with nothing to show draws nothing, and the search stays open, so it appears again as soon as there is something.

Status

  • Set statusText once for each answer: “12 results for tokens”, “No results for tokne”. It is announced when it changes, so changing it on every keystroke would be noise.
  • Set status to loading while a query runs. The loading indicator appears only after a short delay, so a fast answer shows none.
  • Set status to error with a text that says what happened. It is drawn as an error and announced at once.
  • Drop answers that arrive out of order. The search draws whatever you set last.

The shortcut

  • Use a shortcut people already know for search in your kind of product, and write it with mod so that it is right on every keyboard.
  • Set bindShortcut on one search of a screen. Of two searches that bind the same keys, the one shown first keeps them, and debug builds report the other.
  • A shortcut without a modifier, such as /, is ignored while focus is in a text input, so that the person can type the character.
  • If you bind a single character key with no modifier, such as /, give people a way to turn it off or to change it (WCAG 2.1.4, Character Key Shortcuts). bindShortcut is off by default.
  • Without bindShortcut the hint only shows the keys: bind them yourself, or leave shortcut empty.
  • Write a placeholder that says what can be searched: “Search mail”. Set label too: the placeholder is never the name.
  • Update the suggestions as the query changes, and keep them in a stable order while the person moves through them. Put the best match first: one Down Arrow reaches it, and with inlineCompletion it is the one the query is completed from.
  • On select, do what the suggestion promises: open a result, or put a query into the bar and run it.
  • Keep the trailing slot to two icon buttons at most.
  • Give targetLabel (“opens in a new tab”) to a result whose target is new.

Don’t

  • Don’t open the view when the bar merely receives focus. The search already avoids this; don’t add it back yourself.
  • Don’t put controls that need focus of their own, such as a text field, in a docked view. A press on the docked view leaves focus in the input.
  • Don’t change the query when a suggestion becomes active. The search shows it in the input without changing value or emitting input; only a choice (select), the person’s typing or an accepted completion changes the query.
  • Don’t use a search to choose a value in a form.
  • Don’t put a result’s address only in select. A row with no href is a button, and a person cannot open it in a new tab.
  • Don’t mark matches yourself with color alone, or put markup of unknown origin in an excerpt. On the web the excerpt’s content is yours: what you place there is shown as it is.

Accessibility

Role
searchbox
Labeling
label names the search field, the trigger, the suggestions' list, the results' list and the modal views; it is never the placeholder. A suggestion is named by its headline and described by its supporting text; a result by its headline and its excerpt, read as one text with no mention of the marks; a result group by its headline. The status text is announced when it changes, and the loading indicator is named by it. The clear and back buttons are named by clearLabel and backLabel; the slots' icon-only Buttons by their own labels. The search glyph, the leading icons, the drawn shortcut keys, the scrim and the divider are decorative; the shortcut is exposed as the trigger's or the input's keyboard shortcut.
Minimum target
The hit area meets the minimum target size even when the visual size is smaller. minimum 32px · pointer 44px · spacing 8px · touch 48px

Keyboard

Keys Action
Tab / Shift+Tab Moves focus to the leading icon-only Button, the input, the clear button and the trailing icon-only Buttons in turn, or to the trigger. With the docked view open, leaves the search and closes the view. In a modal view (dialog, full-screen) focus stays inside it and Tab goes through the header's controls, the results and the product's own content.
Enter / Space on the trigger Opens the modal view and moves focus to its input.
The shortcut Where the search binds it (bindShortcut): opens the search from anywhere in the window, and closes it again while it is open.
Typing Edits the value and opens the view while it is closed. With suggestions, the first row is the one Enter takes: the query row — the query as typed, so that Enter searches for it — or, with queryRow none, no row, so that Enter does the same. With results and no suggestions, the first result is current, so that Enter opens it. On an on-screen keyboard (the input focused by a touch or a pen) nothing is, so that its Search or Go key submits the query as typed. With inlineCompletion, the query is completed in the input from the first suggestion that begins with it. While a result has focus, returns focus to the input and edits there.
Down Arrow / Up Arrow Opens the view while it is closed. While it is open, moves through the rows in order: the query row (with queryRow none, the input's own place), the suggestions, then the results, across groups; on a suggestion focus stays in the input, and a result takes focus. Down Arrow goes on from the row Enter takes now, so the first press reaches the second row. A suggestion an arrow key reaches is shown in the input without changing the query, and the query as typed comes back on the query row or the input's place. At the ends they go round — Down on the last row to the first, Up on the first to the last — unless wrap is false, which stops them. The row an arrow key moves to is read out at once; a row the search made current is read once typing pauses for half a second.
Left Arrow, Right Arrow, Home, End Move the caret, and leave the row Enter takes as it is. With an inline completion shown, accept it: the completed query becomes the value.
Backspace / Delete, an inline completion shown Takes the completion away and leaves the query as typed; nothing is completed again until the person types.
Enter In the input: chooses the active suggestion (select) or opens the current result; on the query row, or with no row active, submits the value (submit) — completed first where an inline completion is shown — which closes the view unless it shows results or a status. On an on-screen keyboard nothing is made current by itself, so its Search or Go key submits the value as typed. While an input method is composing, Enter confirms the conversion and does nothing else. With Command (Control off Apple keyboards) or Shift, Enter in the input opens the current result in a new tab or a new window, as the link would with that modifier: nothing is emitted and the view stays. On a result: follows the link, as the platform does, modifier keys included.
Enter / Space on the back button Closes the modal view (dialog, full-screen) and returns focus to the bar's input or the trigger: the way out for a person who has neither Escape nor a pointer.
Escape Closes the view and returns focus to the bar's input or the trigger; while the view is closed, clears the value.

Notes

  • Two patterns, by what a row is. Suggestions are queries, in the WAI-ARIA combobox pattern with a listbox popup on the web, in every view: focus stays in the input, and the query as typed is always what Enter takes until the person moves. By default (queryRow first) it is a row of its own, first and active, as the first row of a browser's address bar is (list autocomplete with automatic selection); with queryRow none the input itself is that place and nothing is active, as on a web search page (list autocomplete with manual selection). The arrow keys move through the suggestions and show each in the input without changing the query, and go round at the ends unless wrap is false. inlineCompletion completes the query in the input from a suggestion that begins with it, as an address bar does (list and inline autocomplete). A query suggestion draws what it adds to the query heavier; a result marks what matched. Results are destinations: links in a list, never options, in every view: an option cannot be a link, and a result has to be one (open in a new tab, copy the address, the visited color). Where the view holds results and no suggestion, the first result is current while focus stays in the input, drawn as focused and opened by Enter, as a documentation search does; a result takes real focus once the person moves to it, and the input is a combobox only while the view shows suggestions. A row the search made current by itself — the query row, the first result — is announced once typing pauses for half a second, as React Aria's autocomplete does, so that a screen reader reads the typed character first and then what Enter takes, and not a row after every key; a row an arrow key moves to is announced at once. The dialog and full-screen views are modal dialogs that hold the search field and those links, the pattern of a site search; the docked view with suggestions only is the combobox it was. SwiftUI, Compose, Flutter and React Native have no combobox role: their input is a search field, suggestions are buttons and results are buttons with the link trait or role, each with its position in its list.
  • Overlays: the docked view is an operated overlay that is not modal, and its focus is the input it belongs to until an arrow key takes it to a result; the dialog and full-screen views are modal overlays that take focus, keep it and return it to the bar's input or the trigger.
  • The search never runs a query (SRC-51). The product listens to input, waits as long as its index needs before asking (nothing for an index in memory; a few hundred milliseconds for one over the network), drops an answer that arrives after a newer question, sets status to loading only while it truly waits, and sets statusText once per answer, so that the count is announced once.
  • A shortcut is the product's unless bindShortcut is true. The keyboard shortcut component never listens (KBS-14); the search may, because the command the keys perform is its own: open me.
  • Who closes the view: the search emits toggle; where expanded is a binding or controller (SwiftUI, Flutter) or the element's own property (the web) the search closes it itself, and on Compose and React Native the product sets expanded from toggle, as for the menu.
  • The input edits text as the text field does (TXI-1, TXI-4, TXI-20, TXI-24), and its selection is the text field's pair: comp.input-box.selection.color behind the text, comp.input-box.selection.content.color for it.
  • Heights are minimums: at 200% text size the bar and the header grow, the value stays on one line, and suggestion rows wrap.
  • How a state looks is a value decision of the active design system; components read the state's tokens and never compute the effect themselves.
  • WCAG 2.5.8 (target size): for touch every row of the view is at least the touch target high in both densities (SRC-16). The compact density is lower than the pointer target for a fine pointer, by design: it is the density of a tool used with a mouse and the keyboard, it stays above the 24 by 24 the criterion asks, and its rows reach across the view's whole width. A product that cannot accept that uses regular.

Generated from specs/search.spec.json, tokens/sys/measure.tokens.json

What the component handles

  • The input is a search field named by label, never by the placeholder, with the platform’s search role where it has one.
  • On the web, the docked view follows the WAI-ARIA combobox pattern. While suggestions show, the input is a combobox with aria-autocomplete="list" (both with inlineCompletion), aria-expanded, aria-controls naming the list, and aria-activedescendant naming the active option. The suggestions are a listbox named by label: the query row first, named by the query and described by queryRowText, then each suggestion, named by its headline and described by its supporting text. The active option is the selected one.
  • A row the search makes active by itself, the query row, is named as the active descendant once typing pauses for half a second, as React Aria’s autocomplete does: a screen reader reads the typed character first, then what Enter takes, and not a row after every key. A row an arrow key moves to is named at once. A suggestion’s completion, drawn heavier, is read as part of its headline.
  • Focus in the docked view stays in the input. The query row is active as soon as the view shows suggestions, and again after each change to the query or the suggestions; with queryRow="none" nothing is, and the input itself is the place before the first suggestion. The first Down Arrow goes to the row after the active one. At the ends the keys go round, unless wrap is false. When an active row is partly out of view, the view scrolls it in.
  • On an on-screen keyboard nothing becomes active by itself, neither the query row nor a result, and nothing is completed, so the keyboard’s Search or Go key submits the query as typed, as a search field on a phone does; the person chooses a suggestion by touching it. The search counts the keyboard as on-screen when a touch or a pen gave the input focus, and as a hardware keyboard again after an arrow key, a key that moves the caret, or a mouse press on the input. Whether the device has a touch screen does not tell which keyboard is in use on a laptop with a touch screen or a tablet with a keyboard attached.
  • While an input method is composing, Enter, Escape and the arrow keys belong to it, nothing is active and nothing is completed. The Enter that confirms a conversion chooses nothing, and the query row becomes active once the text is committed.
  • The full-screen view and the dialog view are modal dialogs named by label. Focus moves to the header’s input with the caret at the end of the query, stays inside the view, and everything outside becomes inert and hidden. When the view closes, focus returns to the bar’s input or to the trigger, and the view does not open again.
  • A trigger is a button named by label that says it opens a dialog and whether its view is open. It shows keyboard focus as the bar does.
  • A press on the dialog’s scrim closes it and reaches nothing under it. Its header starts with the back button, which Tab reaches.
  • Results are a list named by label, and a group is named by its headline. A result with an href is a link, never an option; the input is a combobox only while the view shows suggestions. A result is named by its headline and described by its excerpt, then by targetLabel when it opens in a new context.
  • With results and no suggestions, the first result is current while focus stays in the input. It is drawn as focused, and Enter in the input opens it as Enter on the link would. Its link becomes the input’s active descendant once typing pauses for half a second, so a screen reader reads what Enter opens; the input stays a search box. Down Arrow moves focus to the second result, and on through the results, across groups. With Command (Control on other keyboards) or Shift, Enter in the input opens the current result in a new tab or a new window, as that press on the link would; nothing is emitted and the view stays open, so that the person can open another. With suggestions in the view, Down Arrow from the last suggestion moves focus to the first result, and Up Arrow on the first result comes back to the input with the last suggestion active. Typing, deleting or pasting on a result moves focus to the input, where the key then acts. In a modal view Tab goes through the results as through any links.
  • The status row is a live region. statusText is announced when it changes, and at once as an alert while status is error. While loading, the results are marked busy and the loading indicator is named by statusText.
  • The shortcut is exposed as the keyboard shortcut of the trigger or the input. Its hint takes no press and no focus.
  • Focus reaching the input never opens the view, whether by Tab or by returning from the full-screen view.
  • Escape, the platform’s back action and the back button close the view. The docked view also closes on Tab, Shift+Tab, a press outside, or focus leaving the search.
  • The clear and back buttons are Tanrei icon buttons named by clearLabel and backLabel. After clear, focus returns to the input.
  • Your icon buttons in the leading and trailing slots keep their own names, roles and focus stops, in reading order. They are not shown in the full-screen header.
  • Typing, input-method composition, dictation and right-to-left text work as in the text field. The search keyboard’s action key takes the active suggestion or the current result, and submits the query on the query row or when there is neither.
  • The bar shows focus with its own edge, whether focus came from the keyboard or a pointer, as a field does. Suggestion rows show the focus ring inside the row while they are active. Each row and the bar meet the minimum target.
  • The search glyph, the leading icons and the divider are hidden from assistive technology.
  • At larger text sizes the bar and the header grow, the query stays on one line, and suggestion rows wrap.
  • Debug builds report a missing label, clearLabel or backLabel, an empty or repeated suggestion value, an empty headline, an unknown presentation, bar or status, a trigger with the docked presentation, a second search that binds the same keys, and more than two trailing buttons.

Known platform gaps:

  • SwiftUI, Compose, Flutter and React Native do not have the trigger, the dialog view, results, the status row or the shortcut yet. On those platforms, show results in the view’s own content and announce their number yourself.
  • SwiftUI, Compose, Flutter and React Native do not have the query row, inline completion or the keys going round at the ends yet. There, nothing is active until the person moves to a suggestion, Enter submits the query until then, and the arrow keys stop at the ends.
  • Web: a bound shortcut reads mod in the convention its hint is written in, the one an ancestor sets or else the platform’s, where the spec names the platform’s alone.
  • SwiftUI, Compose, Flutter and React Native have no combobox or listbox role. Their input is a search field, and each suggestion is a button with its position in the list, which a screen reader reaches by swiping. The active suggestion is not announced as the input’s active descendant there. Flutter’s suggestions have no position in the list either, and SwiftUI and React Native state the position in English (“2 of 3”; React Native’s positionText changes it).
  • Flutter exposes the input as a search input type, not the search box role, because Flutter 3.32, the oldest version it supports, rejects that role.
  • A press outside the docked view closes it. On the web, SwiftUI, Compose and Flutter the press also reaches what is under it; on React Native it does not, as with the menu.
  • Web: the full-screen header’s input is a combobox too, so the active suggestion is announced there as well. The spec names the combobox only for the docked view.
  • Web: the docked view does not close on the platform’s close request, such as Android’s back gesture. It is placed by script, not with CSS anchor positioning as the spec’s web note says.
  • Disabled reaches the slots’ icon buttons, which the spec leaves in their own state: SwiftUI’s .disabled(true) disables them too, and on the web a disabled opacity below 1 would fade them. Every shipped system’s disabled opacity is 1.
  • SwiftUI draws the docked view above what the search’s own container holds after it, not above every view of the window. Keep the search late in its container, or raise it with zIndex. On macOS the window’s height is not read, so the view always opens below at its natural height, and the full-screen view is a sheet as large as the window.
  • SwiftUI: the selection highlight follows the caret’s tint, not the text field’s selection color. The first tap on an unfocused input puts the caret at the end of the query, not where the tap landed. The keys are tested on macOS only, not with a hardware keyboard on iOS.
  • Compose cannot tell a fine pointer from a touch, so its suggestion rows are always 48 tall where the web’s are 44 under a mouse. A press outside the docked view is not reached by its tests.
  • Flutter: a docked view the product opens with expand() while the input has no focus is not closed by a press outside. The full-screen view needs a Navigator; without one the view is docked.
  • React Native: the docked view is placed when it opens and when the window or the keyboard changes, but does not follow the bar while it scrolls. Escape, the arrow keys and Tab arrive only where TextInput delivers them, and the overlay and the full-screen view’s focus moves have not yet been checked on a device.
  • Under cupertino, the bar draws no focus edge, as an iOS search field shows focus only by its caret and the keyboard.
  • Under m3-like, the search draws the default system’s values: Material’s search values wait for the fidelity reference to cover it. Material’s docked view that grows out of the bar as one surface is drawn as a separate surface under it (mimicry gap search-docked-view-joins-bar).

What you need to do

  • Give the search a label, and give clearLabel and, for the dialog and full-screen, backLabel, in your product’s language.
  • Supply suggestions for the current query, with headlines that make sense read on their own.
  • Say what your search found in statusText, in your product’s language, once for each answer. The search announces it; it does not count results itself.
  • Run the query yourself, and drop answers that arrive out of order.
  • Give every result that has an address an href, and a targetLabel when it opens in a new context.
  • Bind the shortcut’s keys, or set bindShortcut. A hint for keys that do nothing misleads.
  • Decide what select does, and set the query yourself if a choice should fill it in.
  • On Compose and React Native, set expanded from the callback, or the view will not open or close.
  • On the web, give the search a name to submit its query with a form.