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
- Wrapper (
div.console-list-search). - Label (
label for={id};.kit-srwithhideLabel). - Select (
select.kit-select) with[value, text]options.
Variants
hideLabel | Look | When |
|---|---|---|
false (default) | Label above | Forms, Filters rows |
true | Select only | Toolbars (Analytics "All challenges") |
States
| State | Trigger | Look |
|---|---|---|
| Default | — | Native select |
| Focus-visible | focus | The browser's default focus outline (no kit rule targets it) |
| Open | click / Alt+Down | Native 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
- Brand › Analytics › toolbar challenge select.
- Inside
SortSelect; 0.1.xFiltersrows. - Screen: Analytics.
Guidelines
Do
- Start filter options with "All …".
- Use
hideLabelonly 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.
Related
Segmented: few options, visible.ListToolbarselects: v3 toolbar selects.FormField: selects in forms.
See also: Filters · SearchBox · SaveBar
Source
src/kit/ListControls.tsx (line 18) on GitHub.