Saltar al contenido
menumenu tanreiexpand_morecontrasttranslate
tanreiexpand_more
Primeros pasosWebReactSwiftUIJetpack ComposeFlutterReact NativePreajustesTu propio sistema de diseñoUsar Tanrei con agentes de IAMarcaTokens de diseñoSistemas de diseño y personalizaciónTheme StudioColorTipografíaIconosFormaElevaciónMovimientoEstados de interacciónComportamientoDiseño de páginaAccesibilidadTextosTokens de colorTokens de la escala tipográficaTokens de formaTokens de elevaciónTokens de movimientoTokens de estadoTokens de espacio y de medidaComponentesBotónBotón de acción principalBotón segmentadoGrupo de botonesBotón con menúBarra de herramientasBotón de copiarCasilla de verificaciónBotón de opciónInterruptorChipMenúControl deslizanteCampo de control deslizanteCalendarioDateTimePickerGrupo de camposGrupo de botones de opciónGrupo de casillas de verificaciónSelectCampo de selecciónBarra de menúsSubida de archivosSelector de archivos AvanzadoZona de soltar archivosEntrada de texto AvanzadoCampo de textoCampo de chipsCampoCuadro combinado AvanzadoCampo de cuadro combinadoEntrada numérica AvanzadoCampo numéricoEntrada de color AvanzadoCampo de colorEntrada de código de un solo uso AvanzadoCampo de código de un solo usoEntrada de texto incrustada AvanzadoCuadro de redacción de chatTarjetaDivisorCapa modal AvanzadoDiálogoListaFila de listaHoja inferiorHoja lateralCarruselBloque de códigoTablaPopoverPasosAcordeónLista de descripcionesFiguraEstructura de la aplicaciónCabecera de páginaVista de árbolLínea de tiempoVista previa de imágenesTirador de tamañoMarco redimensionableÁrea de desplazamientoInsigniaIndicador de progresoMedidorContador animadoIndicador de cargaSnackbarTooltipAtajo de tecladoTagCódigo en líneaCalloutAvatarEstado vacíoGrupo de tagsEsqueletoElemento de archivoMuestraTexto en marquesinaPestañasVista de pestañasBarra de la aplicaciónBarra de navegaciónPanel de navegaciónBúsquedaEnlacePaginaciónEnlaces anterior y siguienteIndicador de pasosRuta de navegaciónTabla de contenidoTarjeta de enlaceMenú FABEstadoCómo se construye TanreiCómo contribuirLicencia y atribución
InicioComponentesBúsqueda

Búsqueda

Una barra de búsqueda, o un activador compacto que la sustituye, que ofrece sugerencias y resultados mientras se escribe, en una vista acoplada bajo la barra, en un diálogo o sobre toda la pantalla.

content_copyVer en Markdown
Categoría
Navegación
Tokens
comp.search
Nivel
Funcionalidad
Se compone de
Modal layer

Descripción general

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

Generado a partir de docs/status/status.json, specs/search.spec.json

Una especificación revisada que aún no está en todas las plataformas

Esta página describe la búsqueda tal como la define ahora la especificación, también como búsqueda de sitio: un activador en lugar de la barra, una vista de diálogo, resultados que son enlaces, una fila de estado y un atajo. El componente web hace todo esto, y las demostraciones también. SwiftUI, Compose, Flutter y React Native aparecen arriba como rezagados: hasta que se pongan al día ofrecen la revisión anterior (la barra con su campo de entrada, las vistas acoplada y a pantalla completa, y las sugerencias), y sus ejemplos muestran esa revisión.

Vacía, con una consulta y con botones de icono

menumicaccount_circle

Una búsqueda de sitio: un activador de botón con su atajo, un activador de icono y una barra que muestra su atajo. Pulsa un activador para abrir su vista

Sugerencias bajo la fila de la consulta, y autocompletado en línea. Escribe fac y después muévete con las teclas de flecha

Uso

La búsqueda es una barra y una vista. La barra contiene un glifo de búsqueda, el campo de entrada, un botón de borrar mientras hay una consulta y, al final, hasta dos botones de icono tuyos, como la entrada por voz o la cuenta. Tu propio botón de menú o de retroceso puede ocupar el lugar del glifo en el slot leading. La vista se abre mientras la persona busca y contiene, de arriba abajo, las sugerencias, una fila de estado, los resultados y, después, cualquier contenido tuyo.

Una barra o un activador. bar dice qué aparece allí donde se coloca la búsqueda:

  • field (predeterminado): la barra con su campo de entrada.
  • button: un activador con la forma de la barra que no contiene campo de entrada, solo el glifo de búsqueda, el marcador de posición y la indicación del atajo. Úsalo en una cabecera que tenga espacio.
  • icon: un botón de solo icono que muestra el glifo de búsqueda. Úsalo en una cabecera que no lo tenga.

Un activador abre una vista modal, un diálogo o la vista a pantalla completa, y el campo de entrada está en la cabecera de esa vista. Un mismo producto usa button en una ventana ancha e icon en una estrecha.

Tres presentaciones. presentation dice dónde se abre la vista:

  • docked (predeterminada): una superficie justo debajo de la barra, tan ancha como ella, en la capa de superposición de la plataforma, igual que un menú se abre bajo su ancla. El foco se queda en el campo de entrada de la barra, de modo que la persona sigue escribiendo mientras las sugerencias cambian. Si no hay espacio suficiente debajo, la vista se abre encima de la barra.
  • dialog: una superficie modal cerca de la parte superior de la ventana, sobre un velo, con una cabecera que contiene un botón de retroceso, el campo de entrada y el botón de borrar. Es para una ventana grande y se abre desde un activador. Una pulsación en el velo la cierra.
  • full-screen: una vista modal sobre toda la ventana, con la misma cabecera. Toma el foco, lo mantiene y lo devuelve a la barra o al activador cuando se cierra.

Usa la vista acoplada o el diálogo en ventanas grandes y la pantalla completa en las pequeñas. La búsqueda no elige por ti: define presentation a partir de tus propios puntos de ruptura. Un activador con docked abre el diálogo, porque una vista acoplada no tiene campo de entrada propio, y las compilaciones de depuración lo notifican.

Las sugerencias son un tipo de elemento: consultas que la persona puede querer, como una consulta anterior o la continuación de lo que ha escrito. Cada una tiene un value, un headline y, de forma opcional, supportingText y un leadingIcon, como el del historial para una consulta anterior. Tú aportas las sugerencias para la consulta actual; la búsqueda las dibuja y no las filtra. Cuando una sugerencia empieza por la consulta, la parte que añade se dibuja con más peso, como lo hace un buscador web. Elegir una emite select con su valor. La búsqueda nunca cambia la consulta por sí misma, así que tú decides qué significa una elección: normalmente, poner la sugerencia en la barra y buscarla.

La fila de la consulta. Mientras se muestran sugerencias, la primera fila es la consulta tal como se escribió: el glifo de búsqueda y la consulta, y debajo queryRowText si lo das (“Buscar en todo el correo”). Es la activa desde que aparecen las sugerencias, así que Enter siempre busca lo que se escribió, como la primera fila de la barra de direcciones de un navegador; Flecha abajo pasa a las sugerencias. La fila no necesita palabras: el glifo y la consulta ya forman una fila completa. Pon queryRow en none para la otra forma habitual, la de la página de un buscador web: no hay tal fila, nada está activo hasta que la persona se mueve, y hasta entonces Enter busca lo que se escribió.

Moverse por las filas. Las teclas de flecha recorren la fila de la consulta, las sugerencias y después los resultados. La sugerencia a la que llegan se muestra en el campo de entrada sin cambiar la consulta, de modo que Enter elige lo que muestra el campo; al volver a la fila de la consulta, vuelve la consulta tal como se escribió. En los extremos, las teclas dan la vuelta: Flecha abajo en la última fila va a la primera, y Flecha arriba en la primera, a la última. Pon wrap en false para que se detengan en los extremos.

Autocompletado en línea. inlineCompletion completa la consulta en el campo de entrada a partir de la primera sugerencia que empieza por ella, con la parte añadida seleccionada después del cursor, como hace una barra de direcciones. Mover el cursor acepta lo completado, Retroceso lo quita, y Enter lo acepta y busca. Nunca completa tras un borrado o un pegado, mientras un método de entrada está componiendo, ni con un teclado en pantalla. Está desactivado por defecto.

Los resultados son un segundo tipo de elemento, para lo que la búsqueda ha encontrado: una página, una sección, un mensaje. Un resultado tiene un value, un headline, un excerpt y, de forma opcional, un leadingIcon, y lleva a algún sitio: con href, su fila es un enlace real, que la plataforma abre como abre cualquier enlace: en una pestaña nueva con una tecla modificadora, con su propio menú contextual. Sin href, la fila es un botón, y select es la única señal. Un grupo de resultados reúne resultados bajo un mismo título: un título discreto como «Mensajes» o, con un href propio, la página de la que los resultados son secciones. El extracto es un pasaje en el que marcas lo que ha coincidido; la búsqueda no busca la consulta en el texto. En la web, el extracto es el contenido del propio elemento con <mark> alrededor de las coincidencias, o los tramos de excerpt, de los cuales uno de cada dos, empezando por el segundo, es una coincidencia.

El estado. La búsqueda nunca ejecuta una consulta, espera ni filtra: emite input con cada cambio y dibuja lo que le das. Dile qué está haciendo tu búsqueda con status (idle, loading o error) y statusText: el recuento («12 resultados para tokens»), que no se ha encontrado nada o el fallo. La fila de estado muestra el texto y lo anuncia cuando cambia y, durante la carga, muestra un indicador de carga tras un breve retardo.

El atajo. shortcut indica las teclas que abren la búsqueda, con los nombres de tecla del atajo de teclado (mod+k, /). La búsqueda las escribe como una indicación, una línea de texto adaptada al teclado de la persona: al final de un activador de botón, y en la barra mientras está vacía y sin foco. Las expone como el atajo de teclado del activador o del campo de entrada. Las teclas solo funcionan si las vinculas tú o si activas bindShortcut: en ese caso, la búsqueda escucha en toda la ventana mientras se muestra y está habilitada, se abre con esas teclas y se cierra con ellas de nuevo.

Apertura y cierre. Una pulsación en la barra, escribir o Flecha abajo en el campo de entrada abren la vista. El foco, por sí solo, nunca la abre: llegar a la barra con Tab, o que el foco vuelva desde la vista a pantalla completa, la deja cerrada. La búsqueda pide abrirse o cerrarse con toggle, que lleva el nuevo estado y, al cerrar, el motivo: escape, back, select, submit, outside, tab, focus-out o shortcut. La consulta se queda como está cuando la vista se cierra. Mientras se muestran sugerencias, Enter en la fila de la consulta emite submit con la consulta tal como se escribió; si no hay sugerencias, Enter abre el primer resultado, como en la búsqueda de una documentación. Tras submit, la vista permanece abierta mientras muestre resultados o un estado, para que la persona pueda continuar hacia ellos. En la web, el elemento define su propio expanded, y en SwiftUI y Flutter cambia el binding o el controlador. En Compose y React Native defines expanded desde el callback, como en el menú.

<tanrei-search name="q" label="Buscar en el correo" placeholder="Buscar en el correo" clear-label="Borrar búsqueda" query-row-text="Buscar en todo el correo">
  <tanrei-button variant="text" slot="trailing" label="Buscar por voz"><span slot="icon">mic</span></tanrei-button>
  <tanrei-search-suggestion value="invoices" headline="facturas" leading-icon="history"></tanrei-search-suggestion>
  <tanrei-search-suggestion value="folder:invoices" headline="Facturas"
    supporting-text="Carpeta · 24 mensajes" leading-icon="folder"></tanrei-search-suggestion>
  <!-- Los demás hijos son tu propio contenido en la vista, después de las sugerencias. -->
</tanrei-search>

<!-- La forma de la página de un buscador web: sin fila de la consulta y nada activo hasta moverse; las flechas se detienen en los extremos. -->
<tanrei-search label="Buscar en la web" placeholder="Buscar" query-row="none" no-wrap></tanrei-search>

<!-- La forma de una barra de direcciones: la consulta se completa en el campo a partir de la primera sugerencia que empieza por ella. -->
<tanrei-search label="Busca o escribe una dirección" inline-completion></tanrei-search>

<!-- En una ventana pequeña: la vista cubre la ventana y tiene un botón de retroceso. -->
<tanrei-search presentation="full-screen" label="Buscar en el correo" placeholder="Buscar en el correo"
  clear-label="Borrar búsqueda" back-label="Atrás"></tanrei-search>

<!-- Una búsqueda de sitio: un activador con su atajo, una vista de diálogo y resultados que son enlaces. -->
<tanrei-search id="docs-search" bar="button" presentation="dialog" label="Buscar en la documentación" placeholder="Buscar"
  shortcut="mod+k" bind-shortcut clear-label="Borrar búsqueda" back-label="Atrás">
  <!-- Un grupo con href es la página; sus resultados son las secciones encontradas en ella. -->
  <tanrei-search-result-group value="/tokens/" headline="Tokens de diseño" href="/tokens/" leading-icon="article">
    Colores, tamaños y movimiento como <mark>tokens</mark>, en tres niveles.
    <tanrei-search-result value="/tokens/#layers" headline="Capas" href="/tokens/#layers" leading-icon="tag">
      Una capa cambia el valor de un <mark>token</mark> y puede añadir los suyos.
    </tanrei-search-result>
  </tanrei-search-result-group>
  <!-- Los demás hijos son tu propio contenido, después de los resultados. -->
  <tanrei-button variant="text">Cargar más resultados</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)); // se puede cancelar; dentro de un formulario, envía después el formulario
  search.addEventListener('select', (e) => openSuggestion(e.detail.value));
  // El elemento define su propio expanded antes de emitir toggle.
  search.addEventListener('toggle', (e) => log(e.detail.expanded, e.detail.reason));

  // La búsqueda nunca consulta, espera ni espacia las peticiones (debounce): eso es cosa tuya.
  const docs = document.querySelector('#docs-search');
  let asked = 0;
  docs.addEventListener('input', async () => {
    const mine = ++asked;
    docs.status = 'loading';
    docs.statusText = 'Buscando';
    const found = await query(docs.value);
    if (mine !== asked) return; // se hizo una pregunta más reciente: descarta esta respuesta
    show(found); // sustituye los hijos <tanrei-search-result>
    docs.status = 'idle';
    docs.statusText = `${found.length} resultados para ${docs.value}`; // se define una vez por respuesta: se anuncia
  });
  // Se activó un resultado en el mismo lugar. Cancela el evento para entregar el enlace a tu enrutador.
  docs.addEventListener('select', (e) => { /* e.preventDefault(); router.push(e.detail.value); */ });
</script>
import { Button, Search, SearchResult, SearchResultGroup, SearchSuggestion } from '@tanrei/react';

<Search
  label="Buscar en el correo"
  placeholder="Buscar en el correo"
  clearLabel="Borrar búsqueda"
  value={query}
  onInput={(e) => setQuery(e.currentTarget.value)}
  onSubmit={() => runSearch(query)}
  onSelect={(e) => openSuggestion(e.detail.value)}
>
  <Button variant="text" slot="trailing" label="Buscar por voz" 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>

// Una búsqueda de sitio: un activador con su atajo, una vista de diálogo y resultados que son enlaces.
// excerpt son tramos de texto: uno de cada dos, empezando por el segundo, es una coincidencia.
<Search
  bar="button"
  presentation="dialog"
  label="Buscar en la documentación"
  placeholder="Buscar"
  shortcut={['mod+k']}
  bindShortcut
  clearLabel="Borrar búsqueda"
  backLabel="Atrás"
  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

// Cada edición escribe en text; abrir y cerrar escriben en isExpanded.
TanreiSearch("Buscar en el correo", text: $query, isExpanded: $isSearching,
             prompt: Text("Buscar en el correo"), clearLabel: "Borrar búsqueda",
             onSubmit: { value in runSearch(value) },
             onSelect: { value in openSuggestion(value) }) {
    TanreiSearchSuggestion("facturas", leadingIcon: "history", value: "invoices")
    TanreiSearchSuggestion("Facturas", supportingText: "Carpeta · 24 mensajes", leadingIcon: "folder", value: "folder:invoices")
}
import io.github.chnotchy.tanrei.components.TanreiSearch
import io.github.chnotchy.tanrei.components.TanreiSearchSuggestion

// Elevación de estado: tú guardas value y expanded, y los cambias desde los callbacks.
TanreiSearch(
    value = query,
    onValueChange = { query = it },
    expanded = expanded,
    onExpandedChange = { open, _ -> expanded = open }, // el segundo argumento es el motivo
    label = "Buscar en el correo",
    placeholder = "Buscar en el correo",
    clearLabel = "Borrar búsqueda",
    onSearch = { runSearch(query) },
    onSelect = { openSuggestion(it) },
) {
    TanreiSearchSuggestion(value = "invoices", headline = "facturas", leadingIcon = "history")
    TanreiSearchSuggestion(value = "folder:invoices", headline = "Facturas", supportingText = "Carpeta · 24 mensajes", leadingIcon = "folder")
}
import 'package:tanrei/tanrei.dart';

// TanreiSearchController es un TextEditingController que además guarda isExpanded.
final TanreiSearchController search = TanreiSearchController();

TanreiSearch(
  controller: search,
  semanticLabel: 'Buscar en el correo',
  hintText: 'Buscar en el correo',
  clearLabel: 'Borrar búsqueda',
  onChanged: showSuggestionsFor,
  onSubmitted: runSearch,
  onSelected: openSuggestion,
  suggestions: const <TanreiSearchSuggestion>[
    TanreiSearchSuggestion(value: 'invoices', headline: 'facturas', leadingIcon: 'history'),
    TanreiSearchSuggestion(value: 'folder:invoices', headline: 'Facturas', supportingText: 'Carpeta · 24 mensajes', leadingIcon: 'folder'),
  ],
);
import { Search } from '@tanrei/react-native';

// Controlado: tú cambias value y expanded desde onChangeText y onExpandedChange.
<Search
  value={query}
  onChangeText={setQuery}
  expanded={expanded}
  onExpandedChange={(next) => setExpanded(next)}
  accessibilityLabel="Buscar en el correo"
  placeholder="Buscar en el correo"
  clearLabel="Borrar búsqueda"
  onSubmitEditing={() => runSearch(query)}
  onSelect={openSuggestion}
  suggestions={[
    { value: 'invoices', headline: 'facturas', leadingIcon: 'history' },
    { value: 'folder:invoices', headline: 'Facturas', supportingText: 'Carpeta · 24 mensajes', leadingIcon: 'folder' },
  ]}
/>

// En una ventana pequeña: presentation="full-screen" y backLabel="Atrás". El botón Atrás de Android cierra la vista.

Especificaciones

La vista acoplada con una sugerencia, la fila de estado y resultados agrupados, dibujada dentro de la página

Deshabilitada, y la vista acoplada abierta

Anatomía

Propiedades

Propiedad Tipo Valor predeterminado Descripción
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 Descripción
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.

Eventos

Evento Descripción
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).

Elementos

Los tipos de elemento que el componente repite. Un fixture enumera sus elementos en orden; cada plataforma nombra cada tipo según su propio estilo.

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.

Propiedad Tipo Valor predeterminado Descripción
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.
Especificación Web SwiftUI Jetpack Compose Flutter React Native
Elemento tanrei-search-suggestion TanreiSearchSuggestion TanreiSearchSuggestion TanreiSearchSuggestion SearchSuggestion
value · Propiedad value value value value value
headline · Propiedad headline headline headline headline headline
supportingText · Propiedad supportingText supportingText supportingText supportingText supportingText
leadingIcon · Propiedad leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
Notas 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.

Propiedad Tipo Valor predeterminado Descripción
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.
Especificación Web SwiftUI Jetpack Compose Flutter React Native
Elemento tanrei-search-result TanreiSearchResult TanreiSearchResult TanreiSearchResult SearchResult
value · Propiedad value value value value value
headline · Propiedad headline headline headline headline headline
excerpt · Propiedad excerpt excerpt excerpt excerpt excerpt
leadingIcon · Propiedad leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
href · Propiedad href destination href href href
target · Propiedad target target target target target
targetLabel · Propiedad targetLabel targetLabel targetLabel targetLabel targetLabel
Notas 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 · grupo: contiene elementos

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.

Propiedad Tipo Valor predeterminado Descripción
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.
Especificación Web SwiftUI Jetpack Compose Flutter React Native
Elemento tanrei-search-result-group TanreiSearchResultGroup TanreiSearchResultGroup TanreiSearchResultGroup SearchResultGroup
headline · Propiedad headline headline headline headline headline
value · Propiedad value value value value value
excerpt · Propiedad excerpt excerpt excerpt excerpt excerpt
leadingIcon · Propiedad leadingIcon leadingIcon leadingIcon leadingIcon leadingIcon
href · Propiedad href destination href href href
target · Propiedad target target target target target
targetLabel · Propiedad targetLabel targetLabel targetLabel targetLabel targetLabel
Notas 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: [...] }.

Estados

Comportamiento

Requisitos en formato EARS. Cada implementación de plataforma se prueba contra estos identificadores. El texto de los requisitos se muestra tal como está en la especificación, en inglés.

ID Requisito
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.

Correspondencia de nombres por plataforma

Paridad no significa API idénticas. Cada plataforma expresa el mismo contrato con su propio estilo.

Especificación Web SwiftUI Jetpack Compose Flutter React Native
Componente tanrei-search TanreiSearch TanreiSearch TanreiSearch Search
presentation · Propiedad presentation presentation presentation presentation presentation
bar · Propiedad bar bar bar bar bar
value · Propiedad value text value controller value
label · Propiedad label label label semanticLabel accessibilityLabel
placeholder · Propiedad placeholder prompt placeholder hintText placeholder
expanded · Propiedad expanded isExpanded expanded controller expanded
disabled · Propiedad disabled disabled enabled enabled disabled
clearLabel · Propiedad clearLabel clearLabel clearLabel clearLabel clearLabel
backLabel · Propiedad backLabel backLabel backLabel backLabel backLabel
shortcut · Propiedad shortcut shortcut shortcut shortcut shortcut
bindShortcut · Propiedad bindShortcut bindsShortcut bindShortcut bindShortcut bindShortcut
status · Propiedad status status status status status
statusText · Propiedad statusText statusText statusText statusText statusText
queryRow · Propiedad queryRow queryRow queryRow queryRow queryRow
queryRowText · Propiedad queryRowText queryRowText queryRowText queryRowText queryRowText
inlineCompletion · Propiedad inlineCompletion inlineCompletion inlineCompletion inlineCompletion inlineCompletion
wrap · Propiedad wrap wrap wrap wrap wrap
iconSpace · Propiedad iconSpace iconSpace iconSpace iconSpace iconSpace
density · Propiedad density density density density density
input · Evento input text onValueChange onChanged onChangeText
submit · Evento submit onSubmit onSearch onSubmitted onSubmitEditing
select · Evento select onSelect onSelect onSelected onSelect
toggle · Evento toggle isExpanded onExpandedChange onExpandedChanged onExpandedChange
Notas 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 Alias de Valor resuelto (claro)
--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

Representaciones canónicas. Todas las plataformas capturan cada fixture con el mismo identificador para poder comparar los resultados.

Generado a partir de specs/search.spec.json, tokens/comp/search.tokens.json, design/tokens/

Pautas

Cuándo usarlo

Usa la búsqueda cuando buscar sea una de las vías principales de acceso al contenido del producto, como el correo, los archivos, los contactos o los ajustes, y las sugerencias ayuden a llegar antes. Ponla en la parte superior de la pantalla o de la página en la que busca.

Úsala también como búsqueda de sitio: un activador en la cabecera que abre un diálogo, con las páginas y secciones encontradas en forma de enlaces.

Para filtrar una lista corta que ya está en pantalla, o para introducir un término de búsqueda en un formulario, basta con un campo de texto con type search. Elegir un valor de una lista fija es tarea de un menú o de una lista, no de una búsqueda.

La barra o un activador

bar Qué aparece en la página Qué abre Úsalo para
field (predeterminado) La barra con su campo de entrada Cualquier presentación Un producto en el que la búsqueda es una vía principal de acceso y la barra tiene un lugar propio
button Un activador con la forma de la barra: el glifo, el marcador de posición y la indicación del atajo Una vista modal: el diálogo o la pantalla completa Una cabecera con espacio, donde la búsqueda es una cosa entre varias
icon Un botón de solo icono con el glifo de búsqueda Una vista modal: el diálogo o la pantalla completa Una cabecera sin espacio, como en una ventana estrecha

Un activador recibe su nombre de label, y un activador de botón muestra el marcador de posición o, si no lo hay, la etiqueta. Cuando su vista se cierra, el foco vuelve al activador.

Acoplada, diálogo o pantalla completa

Presentación Dónde se abre la vista Foco Úsala para
Acoplada (predeterminada) Debajo de la barra, tan ancha como ella, sobre el contenido Se queda en el campo de entrada de la barra. Nada más queda inerte, y no hay velo Ventanas grandes, donde la vista puede abrirse sin tapar toda la pantalla
Diálogo Cerca de la parte superior de la ventana, centrada, hasta un ancho máximo, sobre un velo. Su parte superior no se mueve mientras su contenido cambia Pasa al campo de entrada de la cabecera, se queda en la vista y vuelve al activador o a la barra cuando se cierra Ventanas grandes, abierta desde un activador: una búsqueda de sitio
Pantalla completa Sobre toda la ventana, con su propia cabecera, botón de retroceso y divisor Pasa al campo de entrada de la cabecera, se queda en la vista y vuelve a la barra o al activador cuando se cierra Ventanas pequeñas, donde las sugerencias y el teclado en pantalla no dejan sitio para nada más

La consulta es la misma en las tres. Cambiar presentation en un punto de ruptura no la modifica.

Los botones de borrar y de retroceso

Los dos vienen incluidos, porque su comportamiento pertenece a la búsqueda: el de borrar vacía la consulta y deja la vista y el foco donde están, y el de retroceso cierra la vista a pantalla completa. Sus nombres deben estar en el idioma de tu producto, así que los das tú: clearLabel («Borrar búsqueda») y, para el diálogo y la pantalla completa, backLabel («Atrás»). En iOS, el botón de retroceso es la única salida de la vista a pantalla completa. La cabecera del diálogo también tiene el botón de retroceso, para que pueda salir de él una persona que no dispone ni de Escape ni de un puntero.

Sugerencias, resultados y tu contenido

  • Una sugerencia es una consulta; un resultado es un lugar al que ir. Una sugerencia ayuda a terminar la consulta, y las teclas de flecha la convierten en la activa mientras el foco se queda en el campo de entrada. Un resultado es algo que tu búsqueda ha encontrado: un enlace que recibe el foco él mismo.
  • No añadas a tus sugerencias la consulta tal como se escribió: eso es la fila de la consulta. Da queryRowText, en el idioma de tu producto, cuando la fila deba decir qué hace Enter (“Buscar en todo el correo”, “Preguntar al asistente”).
  • Elige la forma según lo que sea la búsqueda. Conserva la fila de la consulta (la opción por defecto) cuando Enter deba buscar siempre lo que se escribió, como en una barra de direcciones o en la búsqueda del correo. Usa queryRow="none" en una página de búsqueda con las sugerencias bajo el campo, como la de un buscador web. Una búsqueda cuyas filas son solo resultados, como la de una documentación, no necesita ninguna de las dos: su primer resultado es el que abre Enter.
  • Usa inlineCompletion solo donde la gente escribe hasta el final cosas conocidas, como direcciones o nombres, y completarlas le ahorra teclas. Las páginas de búsqueda no completan en el campo.
  • Usa el icono inicial para distinguir los tipos: el del historial para una consulta anterior, una carpeta, una página, una sección.
  • Cuando solo algunas filas tienen icono, iconSpace decide dónde empiezan su titular las demás. auto (predeterminado) guarda el espacio del icono, vacío, en todas las filas de la vista mientras alguna sugerencia o algún resultado tenga icono, para que los titulares queden alineados; always lo guarda en todas las filas, y never solo en una fila que tiene icono. El menú tiene el mismo iconSpace, con los mismos valores y el mismo valor predeterminado.
  • density fija cuánto espacio ocupa una fila de la vista: regular (el valor por defecto, de 56 de alto) o compact (de 32 de alto con un glifo de 20), para una paleta de comandos o una herramienta que se usa con el ratón y el teclado. Ni la barra ni el texto cambian. Con el tacto una fila nunca es más baja que el objetivo táctil.
  • Escribe titulares cortos y pon el detalle en el texto de apoyo o en el extracto: «Facturas» y, después, «Carpeta · 24 mensajes». Saltan de línea en lugar de cortarse.
  • Marca en el extracto lo que ha coincidido. La marca es la del sistema, un color, un peso mayor y un relleno suave detrás de la coincidencia, de modo que las coincidencias se ven igual en todas partes y se encuentran en cualquier escritura, también donde la fuente no tiene un peso entre el normal y la negrita.
  • Agrupa los resultados cuando vayan juntos: las secciones bajo su página, los mensajes bajo «Mensajes». El título de un grupo es un enlace cuando el propio grupo es un lugar.
  • Da un href a un resultado siempre que tenga una dirección. Así, una persona puede abrirlo en una pestaña nueva, copiar su dirección y ver adónde lleva. Usa select sin href solo para un resultado que tu producto abre por sí mismo.
  • El orden de la vista es fijo: las sugerencias, la fila de estado, los resultados y, después, tu propio contenido, como un botón «Cargar más resultados» o un enlace a una página con todos los resultados.
  • Una vista acoplada sin nada que mostrar no dibuja nada, y la búsqueda sigue abierta, así que vuelve a aparecer en cuanto hay algo.

El estado

  • Define statusText una vez por cada respuesta: «12 resultados para tokens», «Sin resultados para tokne». Se anuncia cuando cambia, así que cambiarlo con cada pulsación de tecla sería ruido.
  • Pon status en loading mientras se ejecuta una consulta. El indicador de carga aparece solo tras un breve retardo, de modo que una respuesta rápida no muestra ninguno.
  • Pon status en error con un texto que diga qué ha pasado. Se dibuja como un error y se anuncia de inmediato.
  • Descarta las respuestas que lleguen desordenadas. La búsqueda dibuja lo último que hayas definido.

El atajo

  • Usa un atajo que las personas ya conozcan para buscar en tu tipo de producto, y escríbelo con mod para que sea correcto en todos los teclados.
  • Activa bindShortcut en una sola búsqueda por pantalla. De dos búsquedas que vinculan las mismas teclas, la que se muestra primero se las queda, y las compilaciones de depuración notifican la otra.
  • Un atajo sin modificador, como /, se ignora mientras el foco está en un campo de entrada de texto, para que la persona pueda escribir el carácter.
  • Si vinculas una sola tecla de carácter sin modificador, como /, ofrece una forma de desactivarla o de cambiarla (WCAG 2.1.4, atajos de teclado con caracteres). bindShortcut está desactivado por defecto.
  • Sin bindShortcut, la indicación solo muestra las teclas: vincúlalas tú, o deja shortcut vacío.

Recomendado

  • Escribe un marcador de posición que diga qué se puede buscar: «Buscar en el correo». Define también label: el marcador de posición nunca es el nombre.
  • Actualiza las sugerencias a medida que cambia la consulta, y mantenlas en un orden estable mientras la persona se mueve por ellas. Pon primero la que mejor coincide: una sola Flecha abajo llega a ella, y con inlineCompletion es la que completa la consulta.
  • Con select, haz lo que la sugerencia promete: abrir un resultado, o poner una consulta en la barra y ejecutarla.
  • Limita el slot final a dos botones de icono como máximo.
  • Da targetLabel («se abre en una pestaña nueva») a un resultado cuyo target sea new.

Evita

  • No abras la vista cuando la barra simplemente recibe el foco. La búsqueda ya lo evita; no lo vuelvas a añadir tú.
  • No pongas en una vista acoplada controles que necesiten un foco propio, como un campo de texto. Una pulsación en la vista acoplada deja el foco en el campo de entrada.
  • No cambies la consulta cuando una sugerencia pasa a ser la activa. La búsqueda la muestra en el campo de entrada sin cambiar value ni emitir input; solo cambian la consulta una elección (select), lo que la persona escribe o un autocompletado aceptado.
  • No uses una búsqueda para elegir un valor en un formulario.
  • No pongas la dirección de un resultado solo en select. Una fila sin href es un botón, y una persona no puede abrirlo en una pestaña nueva.
  • No marques las coincidencias por tu cuenta solo con color, ni pongas en un extracto marcado de origen desconocido. En la web, el contenido del extracto es tuyo: lo que pongas ahí se muestra tal cual.

Accesibilidad

Rol
searchbox
Etiquetado
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.
Objetivo mínimo
El área de pulsación cumple el tamaño mínimo de objetivo aunque el tamaño visual sea menor. minimum 32px · pointer 44px · spacing 8px · touch 48px

Teclado

Teclas Acción
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.

Notas

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

Generado a partir de specs/search.spec.json, tokens/sys/measure.tokens.json

De qué se encarga el componente

  • El campo de entrada es un campo de búsqueda que recibe su nombre de label, nunca del marcador de posición, con el rol de búsqueda de la plataforma donde lo tiene.
  • En la web, la vista acoplada sigue el patrón de cuadro combinado (combobox) de WAI-ARIA. Mientras se muestran sugerencias, el campo de entrada es un cuadro combinado con aria-autocomplete="list" (both con inlineCompletion), aria-expanded, aria-controls que señala la lista y aria-activedescendant que señala la opción activa. Las sugerencias son una lista de opciones (listbox) que recibe su nombre de label: primero la fila de la consulta, que recibe su nombre de la consulta y su descripción de queryRowText, y después cada sugerencia, que recibe su nombre de su titular y su descripción de su texto de apoyo. La opción activa es la seleccionada.
  • La fila que la búsqueda activa por sí sola, la de la consulta, se señala como descendiente activo cuando la escritura se detiene medio segundo, como hace el autocompletado de React Aria: un lector de pantalla lee primero el carácter escrito y después lo que tomará Enter, y no una fila tras cada tecla. La fila a la que lleva una tecla de flecha se señala al instante. La parte completada de una sugerencia, dibujada con más peso, se lee como parte de su titular.
  • En la vista acoplada, el foco se queda en el campo de entrada. La fila de la consulta es la activa en cuanto la vista muestra sugerencias, y vuelve a serlo cada vez que cambian la consulta o las sugerencias; con queryRow="none" no hay ninguna activa, y el propio campo de entrada es el lugar anterior a la primera sugerencia. La primera Flecha abajo va a la fila que sigue a la activa. En los extremos, las teclas dan la vuelta, salvo que wrap sea false. Cuando una fila activa queda parcialmente fuera de la vista, la vista se desplaza hasta mostrarla.
  • Con un teclado en pantalla nada se activa por sí solo, ni la fila de la consulta ni un resultado, y no se completa nada, de modo que la tecla Buscar o Ir del teclado envía la consulta tal como se escribió, como hace un campo de búsqueda en un teléfono; la persona elige una sugerencia tocándola. La búsqueda considera que el teclado está en pantalla cuando un toque o un lápiz dio el foco al campo, y vuelve a considerarlo un teclado físico tras una tecla de flecha, una tecla que mueve el cursor o una pulsación del ratón en el campo. Que el dispositivo tenga pantalla táctil no dice qué teclado se usa en un portátil con pantalla táctil o en una tableta con teclado.
  • Mientras un método de entrada está componiendo, Enter, Escape y las teclas de flecha son suyas, no hay nada activo y no se completa nada. El Enter que confirma una conversión no elige nada, y la fila de la consulta pasa a ser la activa cuando el texto queda confirmado.
  • La vista a pantalla completa y la vista de diálogo son diálogos modales que reciben su nombre de label. El foco pasa al campo de entrada de la cabecera con el cursor de texto al final de la consulta, se queda dentro de la vista, y todo lo de fuera queda inerte y oculto. Cuando la vista se cierra, el foco vuelve al campo de entrada de la barra o al activador, y la vista no se abre de nuevo.
  • Un activador es un botón que recibe su nombre de label y que dice que abre un diálogo y si su vista está abierta. Muestra el foco del teclado como lo hace la barra.
  • Una pulsación en el velo del diálogo lo cierra y no llega a nada de lo que hay debajo. Su cabecera empieza con el botón de retroceso, al que se llega con Tab.
  • Los resultados son una lista que recibe su nombre de label, y un grupo recibe su nombre de su titular. Un resultado con href es un enlace, nunca una opción; el campo de entrada es un cuadro combinado solo mientras la vista muestra sugerencias. Un resultado recibe su nombre de su titular y su descripción de su extracto y, después, de targetLabel cuando se abre en un contexto nuevo.
  • Con resultados y sin sugerencias, el primer resultado es el actual mientras el foco sigue en el campo de entrada. Se dibuja como enfocado, y Enter en el campo de entrada lo abre como lo haría Enter sobre el enlace. Su enlace pasa a ser el descendiente activo del campo cuando la escritura se detiene medio segundo, de modo que un lector de pantalla lee lo que abrirá Enter; el campo sigue siendo un cuadro de búsqueda. Flecha abajo lleva el foco al segundo resultado, y de ahí a los siguientes, de un grupo a otro. Con Comando (Control en otros teclados) o Mayúsculas, Enter en el campo de entrada abre el resultado actual en una pestaña nueva o en una ventana nueva, como lo haría esa pulsación sobre el enlace; no se emite nada y la vista sigue abierta, para que la persona pueda abrir otro.
  • Con sugerencias en la vista, Flecha abajo en la última sugerencia lleva el foco al primer resultado, y Flecha arriba en el primer resultado vuelve al campo de entrada con la última sugerencia activa. Escribir, borrar o pegar sobre un resultado lleva el foco al campo de entrada, donde la tecla actúa entonces. En una vista modal, Tab recorre los resultados como recorre cualquier enlace.
  • La fila de estado es una región activa (live region). statusText se anuncia cuando cambia, y de inmediato, como una alerta, mientras status es error. Durante la carga, los resultados se marcan como ocupados y el indicador de carga recibe su nombre de statusText.
  • El atajo se expone como el atajo de teclado del activador o del campo de entrada. Su indicación no recibe pulsaciones ni foco.
  • Que el foco llegue al campo de entrada nunca abre la vista, ya sea con Tab o al volver desde la vista a pantalla completa.
  • Escape, la acción de retroceso de la plataforma y el botón de retroceso cierran la vista. La vista acoplada se cierra además con Tab, con Mayús+Tab, con una pulsación fuera o cuando el foco sale de la búsqueda.
  • Los botones de borrar y de retroceso son botones de icono de Tanrei que reciben su nombre de clearLabel y backLabel. Después de borrar, el foco vuelve al campo de entrada.
  • Tus botones de icono de los slots leading y trailing conservan sus propios nombres, roles y paradas de foco, en el orden de lectura. No se muestran en la cabecera de la pantalla completa.
  • La escritura, la composición con un método de entrada, el dictado y el texto de derecha a izquierda funcionan como en el campo de texto. La tecla de acción del teclado de búsqueda toma la sugerencia activa o el resultado actual, y envía la consulta en la fila de la consulta o cuando no hay ninguno de los dos.
  • La barra muestra el foco con su propio borde, tanto si el foco llegó desde el teclado como desde un puntero, como hace un campo. Las filas de sugerencia muestran el anillo de foco dentro de la fila mientras están activas. Cada fila y la barra cumplen el objetivo mínimo.
  • El glifo de búsqueda, los iconos iniciales y el divisor quedan ocultos para la tecnología de apoyo.
  • Con tamaños de texto mayores, la barra y la cabecera crecen, la consulta se mantiene en una línea y las filas de sugerencia saltan de línea.
  • Las compilaciones de depuración notifican la falta de label, clearLabel o backLabel, un valor de sugerencia vacío o repetido, un titular vacío, una presentación, una barra o un estado desconocidos, un activador con la presentación acoplada, una segunda búsqueda que vincula las mismas teclas y más de dos botones finales.

Carencias conocidas por plataforma:

  • SwiftUI, Compose, Flutter y React Native todavía no tienen el activador, la vista de diálogo, los resultados, la fila de estado ni el atajo. En esas plataformas, muestra los resultados en el contenido propio de la vista y anuncia tú cuántos son.
  • SwiftUI, Compose, Flutter y React Native todavía no tienen la fila de la consulta, el autocompletado en línea ni las teclas que dan la vuelta en los extremos. Allí, nada está activo hasta que la persona pasa a una sugerencia con las teclas de flecha, Enter envía la consulta hasta entonces, y las flechas se detienen en los extremos.
  • Web: un atajo vinculado lee mod según la convención en la que está escrita su indicación, la que define un ancestro o, si no, la de la plataforma, mientras que la especificación solo nombra la de la plataforma.
  • SwiftUI, Compose, Flutter y React Native no tienen rol de cuadro combinado ni de lista de opciones. Su campo de entrada es un campo de búsqueda, y cada sugerencia es un botón con su posición en la lista, al que un lector de pantalla llega deslizando. Ahí, la sugerencia activa no se anuncia como el descendiente activo del campo de entrada. Las sugerencias de Flutter tampoco tienen posición en la lista, y SwiftUI y React Native indican la posición en inglés («2 of 3»; el positionText de React Native la cambia).
  • Flutter expone el campo de entrada como un tipo de entrada de búsqueda, no con el rol de cuadro de búsqueda, porque Flutter 3.32, la versión más antigua que admite, rechaza ese rol.
  • Una pulsación fuera de la vista acoplada la cierra. En la web, SwiftUI, Compose y Flutter, la pulsación llega además a lo que hay debajo; en React Native no, como ocurre con el menú.
  • Web: el campo de entrada de la cabecera de la pantalla completa también es un cuadro combinado, así que la sugerencia activa se anuncia igualmente ahí. La especificación solo nombra el cuadro combinado para la vista acoplada.
  • Web: la vista acoplada no se cierra con la petición de cierre de la plataforma, como el gesto de retroceso de Android. Se coloca mediante un script, no con el posicionamiento por anclas de CSS como dice la nota para la web de la especificación.
  • El estado deshabilitado alcanza a los botones de icono de los slots, que la especificación deja en su propio estado: el .disabled(true) de SwiftUI los deshabilita también, y en la web una opacidad de deshabilitado inferior a 1 los atenuaría. La opacidad de deshabilitado de todos los sistemas incluidos es 1.
  • SwiftUI dibuja la vista acoplada por encima de lo que el propio contenedor de la búsqueda contiene después de ella, no por encima de todas las vistas de la ventana. Coloca la búsqueda hacia el final de su contenedor, o súbela con zIndex. En macOS no se lee la altura de la ventana, así que la vista siempre se abre debajo con su altura natural, y la vista a pantalla completa es una hoja tan grande como la ventana.
  • SwiftUI: el resaltado de la selección sigue el tinte del cursor de texto, no el color de selección del campo de texto. El primer toque en un campo de entrada sin foco pone el cursor de texto al final de la consulta, no donde cayó el toque. Las teclas se prueban solo en macOS, no con un teclado físico en iOS.
  • Compose no puede distinguir un puntero fino de un toque, así que sus filas de sugerencia miden siempre 48 de alto, mientras que las de la web miden 44 con un ratón. Sus pruebas no alcanzan una pulsación fuera de la vista acoplada.
  • Flutter: una vista acoplada que el producto abre con expand() mientras el campo de entrada no tiene el foco no se cierra con una pulsación fuera. La vista a pantalla completa necesita un Navigator; sin él, la vista es acoplada.
  • React Native: la vista acoplada se coloca cuando se abre y cuando cambian la ventana o el teclado, pero no sigue a la barra mientras esta se desplaza. Escape, las teclas de flecha y Tab llegan solo donde TextInput las entrega, y la superposición y los movimientos del foco de la vista a pantalla completa aún no se han comprobado en un dispositivo.
  • Con cupertino, la barra no dibuja borde de foco, ya que un campo de búsqueda de iOS muestra el foco solo con su cursor de texto y con el teclado.
  • Con m3-like, la búsqueda dibuja los valores del sistema predeterminado: los valores de búsqueda de Material esperan a que la referencia de fidelidad la cubra. La vista acoplada de Material, que crece desde la barra como una sola superficie, se dibuja como una superficie aparte debajo de ella (laguna de imitación search-docked-view-joins-bar).

Qué debes hacer tú

  • Da a la búsqueda un label, y da clearLabel y, para el diálogo y la pantalla completa, backLabel, en el idioma de tu producto.
  • Aporta sugerencias para la consulta actual, con titulares que tengan sentido leídos por sí solos.
  • Di en statusText lo que ha encontrado tu búsqueda, en el idioma de tu producto, una vez por cada respuesta. La búsqueda lo anuncia; no cuenta los resultados por sí misma.
  • Ejecuta tú la consulta, y descarta las respuestas que lleguen desordenadas.
  • Da un href a todo resultado que tenga una dirección, y un targetLabel cuando se abra en un contexto nuevo.
  • Vincula las teclas del atajo, o activa bindShortcut. Una indicación de teclas que no hacen nada induce a error.
  • Decide qué hace select, y define tú la consulta si una elección debe rellenarla.
  • En Compose y React Native, define expanded desde el callback, o la vista no se abrirá ni se cerrará.
  • En la web, da a la búsqueda un name para enviar su consulta con un formulario.