Choice switch
Choose a compact horizontal preset without nested button surfaces.
Interactive example
Usage
<ChoiceSwitch label="Quick filters" items={[{id:"wholesale",label:"Wholesale"},{id:"unassigned",label:"Without a company"}]} selected={preset} onSelect={setPreset} />Properties
| Property | Type | Default | Description |
|---|---|---|---|
| items | {id,label}[] | Required | Stable alternatives. |
| selected | string | Required | Active ID; empty means manual conditions. |
| onSelect | (id)=>void | Required | Host replaces conditions. |
| label | string | Quick filters | Accessible group name. |
Design & interaction
Exclusive horizontal presets with one HTML button surface, native check icons and aria-pressed semantics. Native s-press-button exposes secondary/tertiary only, so this Kaupvik pattern provides the requested dark selected surface with white text. Arrow/Home/End switch and focus; host clears selection after manual filter edits. Keep one consistent pill radius and no nested frame.
Accessibility
Native button pressed state; arrow keys, Home and End move focus and selection. Space/Enter activate. Each option remains natively keyboard accessible; selection is also shown by a native check icon. Wrap on narrow screens.
Open-source source
Available in github.com/Kaupvik/kaupvik-polaris ↗. Host apps supply authentication, native persistence, and read-back state.