Search Field
SearchField composes a native search input, a conditional clear button and a
submit button inside one visual control. Use it inside a native form. The submit
button keeps the form’s normal submission behavior.
Import
Section titled “Import”<script> import SearchField from "@invisible-ui/svelte/SearchField.svelte";</script><script setup> import { SearchField } from "@invisible-ui/vue";</script>import { SearchField } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-search-field></ds-search-field><form role="search" onsubmit={search}> <SearchField label="Search tables and columns" hideLabel name="query" bind:value={query} /></form>In Elements:
<form role="search"> <ds-search-field label="Search tables and columns" hide-label name="query" ></ds-search-field></form>The clear button appears only when the field has a value. It reports an empty
value once and returns focus to the search input. clearLabel / clear-label
and submitLabel / submit-label override the localized accessible names.
The component provides its own clear button because browsers do not expose a consistent native cancel affordance. It suppresses the browser-specific cancel glyph only inside this component, avoiding duplicate controls in Chromium and WebKit while keeping the same behavior in Firefox.
Filter as you type
Section titled “Filter as you type”When the results update on every keystroke, there is nothing to submit. Turn
the submit button off with submitButton={false} (submit-button="false" in Elements):
the search glyph moves to the start of the field as a decorative mark, and the
clear button stays.
6 tables
- accounts
- archive
- audit_log
- invoices
- orders
- users
<SearchField label="Filter tables" hideLabel submitButton={false} bind:value={query} />Announce the result count in a polite live region, so a screen reader user hears the effect of each change.
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Visible label and accessible name of the search input. |
hideLabel | boolean | false | Visually hide the label while preserving the accessible name. |
value | string | "" | Initial or controlled search query. |
placeholder | string | undefined | undefined | Native input placeholder. It does not replace the label. |
disabled | boolean | false | |
required | boolean | false | |
readOnly | boolean | false | |
name | string | undefined | undefined | Native form field name. |
autocomplete | HTMLInputAttributes["autocomplete"] | undefined | undefined | Native browser autofill hint. |
clearLabel | string | undefined | undefined | Accessible name for the conditional clear button. |
submitLabel | string | undefined | undefined | Accessible name for the native submit button. |
submitButton | boolean | true | Render the submit button; turn it off for a filter that applies as you type. |
onValueChange | ((value: string) => void) | undefined | undefined | Called once after a user edit or clear action is committed locally. |
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Visible label and accessible name of the search input. |
hideLabel | boolean | false | Visually hide the label while preserving the accessible name. |
modelValue | string | undefined | Controlled query for v-model. |
value | string | "" | Initial or controlled search query. |
placeholder | string | undefined | Native input placeholder. It does not replace the label. |
disabled | boolean | false | |
required | boolean | false | |
readOnly | boolean | false | |
name | string | undefined | Native form field name. |
autocomplete | string | undefined | Native browser autofill hint. |
clearLabel | string | undefined | Accessible name for the conditional clear button. |
submitLabel | string | undefined | Accessible name for the native submit button. |
submitButton | boolean | true | Render the submit button; turn it off for a filter that applies as you type. |
onValueChange | (value: string) => void | undefined | Called once after a user edit or clear action is committed locally. |
| Event | Payload |
|---|---|
update:modelValue | value: string |
| Prop | Type | Default | Description |
|---|---|---|---|
label * | string | — | Visible label and accessible name of the search input. |
hideLabel | boolean | false | Visually hide the label while preserving the accessible name. |
value | string | "" | Initial or controlled search query. |
placeholder | string | — | Native input placeholder. It does not replace the label. |
disabled | boolean | false | |
required | boolean | false | |
readOnly | boolean | false | |
name | string | — | Native form field name. |
autoComplete | InputHTMLAttributes<HTMLInputElement>["autoComplete"] | — | Native browser autofill hint. |
clearLabel | string | — | Accessible name for the conditional clear button. |
submitLabel | string | — | Accessible name for the native submit button. |
submitButton | boolean | true | Render the submit button; turn it off for a filter that applies as you type. |
onValueChange | (value: string) => void | — | Called once after a user edit or clear action is committed locally. |
| Attribute | Reactive | Description |
|---|---|---|
label * | yes | |
hide-label | yes | |
value | yes | |
placeholder | yes | |
description | yes | |
error | yes | |
disabled | yes | |
readonly | yes | |
required | yes | |
name | yes | |
autocomplete | yes | |
clear-label | yes | |
submit-label | yes | |
submit-button | yes | "false" drops the submit button for a filter that applies as you type |
Reactive attributes re-render the element when they change after the first render.
Properties: value.
Emits: bubbling input and change CustomEvents, both with detail.value.
Accessibility
Section titled “Accessibility”- Keep the real label.
hideLabelhides it only visually. - The clear and submit icons are decorative; their buttons have accessible names.
- Keyboard order is input, clear when present, then submit when present.
- Enter in the input follows native form submission.
- Disabled and read-only search fields do not expose a clear action.