Skip to Content
BBRICKSv0.7.4
KitForms

SelectBox

A labelled choice (a status filter, a sort order).

import { SelectBox } 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 SelectBox. Written in docs/content/components/SelectBox.md; the props above are read from the code, which wins where the two disagree.

A labelled native select for a filter or a choice; use it for a status filter or a "Challenge" pick in a toolbar.

SelectBox is a <label> over a native <select class="kit-select">, typed by its option values. hideLabel keeps the label for screen readers only, for a filter row whose "All …" option already names it. It is a native control, so keyboard and mobile pickers work as users expect.

Anatomy

  1. Wrapper (div.console-list-search).
  2. Label (label for={id}; .kit-sr with hideLabel).
  3. Select (select.kit-select) with [value, text] options.

Variants

hideLabelLookWhen
false (default)Label aboveForms, Filters rows
trueSelect onlyToolbars (Analytics "All challenges")

States

StateTriggerLook
Default—Native select
Focus-visiblefocusThe browser's default focus outline (no kit rule targets it)
Openclick / Alt+DownNative list

Usage

The Analytics toolbar:

<Toolbar
  filters={<>
    <Segmented label="Range" value={range} onChange={setRange} options={[['7', '7 days'], ['30', '30 days'], ['90', '90 days']]} />
    <SelectBox id="an-challenge" label="Challenge" hideLabel value={challenge} onChange={setChallenge}
      options={[['all', 'All challenges'], ['winter', 'Winter glow launch'], ['campus', 'Back to campus']]} />
  </>}
  actions={<Button size="sm">Export CSV</Button>} />
<SelectBox id="status" label="Status" value={status} onChange={setStatus}
  options={[['all', 'All'], ['active', 'Active'], ['paused', 'Paused']]} />

Where it appears

Guidelines

Do

  • Start filter options with "All …".
  • Use hideLabel only when the first option names the filter.

Don't

  • Don't use it for 2–3 options shown at once; use Segmented.

RTL and Arabic

  • Native select mirrors with the page; the arrow side follows.

Tokens

Inherits .kit-select styling; inside Filters: --control-h, --color-control-border.

Accessibility

  • Native select with a real label (visible or .kit-sr).

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: Filters · SearchBox · SaveBar

Source

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

On this page