GitHubGitHub
← All components
Forms / component

Search field

The toolbar search input: leading glyph, accent focus ring, and a clear button that restores focus and re-reports the empty query.

EmptyWith queryDisabled

4 of 4 services

<SearchField bind:value={search} placeholder="Search services" />

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { SearchField } from '@chanrg/4ui';<SearchField bind:value={search} placeholder="Search services" />

With query

The clear button appears once there is a query, and restores focus to the input.

1 of 4 services

<SearchField bind:value={query} placeholder="Search services" />

Disabled

Blocks input while a request is in flight.

Input is blocked while the request is in flight

<SearchField bind:value={query} placeholder="Search services" disabled />

API reference

Props

PropTypeDefaultDescription
valuestring''Bindable query.
oninput(value: string) => voidCalled on every keystroke and on clear.
placeholder / ariaLabelstring'' / placeholderThe accessible name falls back to the placeholder.
clearLabelstring'Clear search'Label of the clear button.
disabledbooleanfalseBlocks input.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.

Accessibility

  • The wrapper is a search landmark and the input always carries a name.
  • Clearing returns focus to the input so typing can continue.

Dependencies

Icon