Skip to content

BbSwitchGroup

Several related on/off settings bound to one array, saved on every flip or with the form.

import { BbSwitchGroup } from 'bitboss-ui';

On this page

Use it for

Use BbSwitchGroup for related states of things: storefront sections, feature flags, or notification channels.

Use something else when

Also see: Options and items.

The items, mapping, async provider, and coherence API is shared with BbCheckboxGroup. This page covers the switch-specific decisions.

Passthrough

Hover or tap a part to outline it. The toggles turn on loading, errors and warnings where the component has them; only parts get a row.

Shown under the label as lasting context.
Guidance while the control is focused.

Save settings on every flip

For a live settings panel, apply the next array optimistically, hold the group readonly during the request, and restore the previous array on failure.

Sections visible in the storefront

Turn Displays off: the save is refused and the switch goes back. Bind :model-value with @update:model-value when rollback matters; the event carries the whole next array. Report a refused save in a status line or a toast rather than in errors, which paints every row of the group. Inside a BbForm do none of this: the group joins the form under its name and submits the array with everything else.

The settings-list shape comes from list-layout="vertical-stretch", item-layout="label-fill" and item-reverse; the second line of each row is item-props. When each setting is its own field rather than a member of one array, use separate BbSwitch rows.

Explain unavailable switches

max disables the switches that are off once the cap is reached, and leaves the ones that are on free to trade.

Escalate toTwo teams at a time. Turn one off to pick another.

1 of 2 used

State the rule in description; an unexplained switch that does not move looks broken. To lock specific items, pass selectable a predicate, as on BbCheckboxGroup: the predicate locks the items it rejects and max caps the rest. To freeze the whole group, use readonly when the values must still submit and disabled when they must not.

Coming from v2disabled on an item → selectable

A disabled field on an item is ignored in v3. Move that condition into selectable.

Choose the model shape

Multiple mode is the default: the model is an array (unbound, it starts empty; null throws). :multiple="false" emits one bare value or null.

Primary data residencyExactly one region holds the primary copy of your data.

Model: 'IT'

Use stable primitive values, not whole domain objects. { label, value } items work as they are; for any other shape name the fields with item-value and item-text. An object with none of those fields becomes the model value whole, and its label is its JSON.

Coming from v2single-value mode now works

v2 accepted :multiple="false" and ignored it, so the model stayed an array. v3 honours it and emits a bare value or null. Audit existing models before upgrading.

Lay out the rows

Rows wrap on one line by default, as in Editor, where compact also tightens the spacing. list-layout stacks them (vertical, Daily digest) or turns them into equal boxes (tiles, Ship to).

Editor
Daily digest
Ship to