Skip to Content
BBRICKSv0.7.4
KitForms

SearchBox

A labelled search box; the list it filters waits for a pause in typing (useDebounced).

import { SearchBox } from '@ergasti/bricks';

Examples

Filter row

The older labelled search and select, in the Filters row (ListToolbar is the standard now; see Deprecated APIs). hideLabel keeps the label for screen readers only.

Code
import { useState } from 'react';
import { Filters, SearchBox, SelectBox } from '@ergasti/bricks';

function Row() {
  const [q, setQ] = useState('');
  const [tier, setTier] = useState('');
  return (
    <Filters>
      <SearchBox id="docs-q" label="Search" value={q} onChange={setQ} />
      <SelectBox id="docs-tier" label="Tier" hideLabel value={tier} onChange={setTier} options={[['', 'All tiers'], ['rising', 'Rising'], ['elite', 'Elite']]} />
    </Filters>
  );
}

Props

Prop

Type

Design guidance

How the BRICKS design system uses SearchBox. Written in docs/content/components/SearchBox.md; the props above are read from the code, which wins where the two disagree.

A labelled search field for filtering a list; use it inside Filters on 0.1.x lists.

SearchBox is a <label> over an <input type="search"> (dir="auto", no autocomplete, 100 characters max). It is controlled: you hold the value and debounce the fetch in the list that reads it. v3 screens use ListToolbar's search slot (with an icon, built-in debounce and a clear button).

Anatomy

  1. Wrapper (div.console-list-search): column, 5px gap.
  2. Label (label for={id}): 13px 500.
  3. Input (input type="search"): 44px tall on its own (console list style), 10px radius, #D9DFEA border; inside Filters it takes --control-h (38px on desktop, 44px on touch screens).

Variants

None. Inside Filters it takes the row's free space and --control-h height.

States

StateTriggerLook
Emptyvalue=""Empty field
With valuetextNative search clear (×) where the browser shows one
Focus-visiblefocusConsole focus outline
Mixed scriptArabic typeddir="auto" flips the field

Usage

const [q, setQ] = useState('');
const query = useDebounced(q, 300);

<Filters>
  <SearchBox id="coupon-q" label="Search coupons" value={q} onChange={setQ} />
</Filters>

Where it appears

  • 0.1.x console lists. v3: ListToolbar search.
  • Kit gallery.

Guidelines

Do

  • Debounce before fetching.
  • Say what is searched in the label ("Search coupons").

Don't

  • Don't rely on a placeholder instead of the label.

RTL and Arabic

  • dir="auto" per value.

Tokens

None (console colours); inside Filters: --control-h, --color-control-border.

Accessibility

  • A real <label for> names the field; type="search" exposes it as a searchbox (it is not a search landmark: wrap the list's controls in <search> or role="search" yourself if you want one).
  • dir="auto" reads mixed-language input in the right order.
  • No kit focus rule targets it: it shows the browser's default focus outline.
  • The list it filters does not announce results by itself; pair it with a polite result count (Pager's summary does this).

Found in the source

  • Roles in the markup: alert.
  • ARIA attributes set: aria-label, aria-live, aria-hidden, aria-current.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: FormField · SaveBar · Segmented

Source

src/kit/ListControls.tsx (line 8) on GitHub.

On this page