Search Field
A search box with a search glyph, a clear button, Enter to submit and Escape to clear, as a form control.
Angular: available Vue: available React: available React Native: available
Usage
Searched for: nothing yet
<div class="demo-stack" style="max-width: 24rem">
<sone-search-field
[(value)]="query"
clearable
placeholder="Search notes"
ariaLabel="Search notes"
(submit)="submitted.set($event)"
/>
<p role="status" style="margin: 0; color: var(--text-secondary)">
Searched for: {{ submitted() || "nothing yet" }}
</p>
<sone-search-field size="sm" placeholder="Filter" ariaLabel="Filter sources" />
<!-- variant="filled": a grey fill, no border; the glyph and placeholder name it -->
<sone-search-field variant="filled" placeholder="Search chats" ariaLabel="Search chats" />
</div>Import
import {
SoneSearchFieldComponent,
} from "@surface-one/angular/search-field";API reference
SoneSearchFieldComponentComponent
`<sone-search-field>` — a search box on the Input Group: a leading search glyph, the field (`role="searchbox"`) and, when `clearable` and not empty, a clear button at the end. A form control (ControlValueAccessor) or `[(value)]`. Enter emits `(submit)` with the current text. Escape clears a `clearable` field that has text; on an empty (or non-clearable) field it emits `(escape)` — close the panel that holds it there. `focus()` focuses the field.
| Name | Type | Default |
|---|---|---|
valuetwo-wayThe search text (`[(value)]`). | string | "" |
size | SearchFieldSize | "default" |
variant`filled`: a grey fill and no border (Isles' search box); it takes the field colour on focus and keeps the focus ring. The search glyph and the placeholder identify it in place of a 3:1 border. | SearchFieldVariant | "default" |
placeholder | — | $localize`Search` |
ariaLabelThe field's accessible name. | string | null | $localize`Search` |
inputId | string | null | null |
name | string | null | null |
clearableShows a clear button while the field has text; Escape clears it too. | boolean | false |
clearLabelThe clear button's accessible name. | — | $localize`Clear search` |
disabled | boolean | false |
| Name | Type |
|---|---|
submitEnter was pressed; carries the current text. | string |
escapeEscape was pressed on an empty or non-clearable field. | void |