Available · v0.4.0
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 and 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.
Implementation and ownership
Source: Kaupvik Website, packages/polaris. React client component; controlled host data. No API credentials or merchant transport are included. Host applications own authentication, validation, localization, errors and persisted preferences. Graph nodes use native Shopify identities; diagram positions are presentation only.
Tokens and states
Native controls use Shopify attributes and inherit the host’s design system. Kaupvik layout tokens: --kp-surface, --kp-surface-subdued, --kp-ink, --kp-ink-subdued, --kp-border, --kp-accent, --kp-focus, --kp-radius, --kp-space. Override only within the product surface. Loading, error and empty states are distinct; host data is never invented to fill a preview.
Verification
Test keyboard and pointer operation, focus visibility, 375px and desktop layouts, reduced motion and server hydration. Test every product adapter independently before release. QO remains on its reviewed implementation until its own adoption release.
Related product patterns