Kaupvik KeelKaupvik Keel
Open Source · v0.4.0

Choice switch

Choose a compact horizontal preset without nested button surfaces.

Interactive example

Loading Polaris web components…

Usage

<ChoiceSwitch label="Quick filters" items={[{id:"wholesale",label:"Wholesale"},{id:"unassigned",label:"Without a company"}]} selected={preset} onSelect={setPreset} />

Properties

PropertyTypeDefaultDescription
items{id,label}[]RequiredStable alternatives.
selectedstringRequiredActive ID; empty means manual conditions.
onSelect(id)=>voidRequiredHost replaces conditions.
labelstringQuick filtersAccessible 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.