Props
| Name | Type | Default | Description |
|---|---|---|---|
autofocus | Booleanish | undefined | - | Sets autofocus on page load. |
compact | boolean | undefined | false | Displays the component in a compact version. See example |
dependencies | unknown[] | undefined | - | Defines an array of dependencies that will trigger actions in the component upon change. |
depsDebounceTime | number | undefined | - | Timeout used to debounce response to changes to dependencies. |
description | string | undefined | - | Descriptive text displayed below the label and above the input. Unlike the hint it is always
visible, and it is linked to the input via One description for the whole set. It is also the only place |
direction | InputDirection | undefined | - | Direction of the layout of the component. Can either be a predefined value or a pattern separated by a space like |
disabled | boolean | undefined | false | Disables the component. Currently exempts options that are already on, so a disabled group can still be switched off. Use |
enforceCoherence | boolean | undefined | false | If coherence is enforced the input cannot have a modelValue that is incoherent with its current items. e.g. You cannot set v-model to a user that is not present in the items passed. modelValue will be reset upon incoherence. |
errors | string | string[] | undefined | - | Can be a string or an array of string containing the messages to display.
They render in an One channel for the fieldset. On an instant-save group it is where a refused write explains itself — pair it with a toast, since the group may be off screen by then. See example |
hasErrors | boolean | undefined | false | Define if the component should be in an error state. It usually attaches a CSS class for styling purposes. |
hasWarnings | boolean | undefined | false | Define if the component should be in a warning state.
Same chrome as errors with |
hideLabel | boolean | undefined | false | Visually hides each option's label text (the text rendered next to every
input) while keeping it accessible to screen readers.
Does not affect the fieldset legend — use |
hideLegend | boolean | undefined | false | Visually hides the legend of the fieldset while maintaining accessibility. |
hint | string | undefined | - | Text box to be displayed near the input, usually to indicate instructions. |
id | string | undefined | - | The identifier of the component. |
inputDirection | "horizontal" | "vertical" | undefined | - | Defines the direction of the inputs in the fieldset. See example |
inputPosition | "left" | "center" | "right" | undefined | "left" | Sets the alignment of the input. Since inputs are inline block they can be aligned just as text can. |
itemProps | BbOptionGroupItemProps<T> | undefined | - | ADDITIONAL row fields resolved from each item — never its text or value
(those stay on |
itemsrequired | T[] | ((prefill: boolean, modelValue?: any) => T[] | Promise<T[]>) | - | Used to retrieve items; can be an array or a function. Same mapping as BbCheckboxGroup, down to the accessors and the silent de-duplication by resolved value. See example |
itemText | ItemAccessor<T, string> | undefined | - | Defines a path that returns a property of the object to use as text or a function that returns a string. See example |
itemValue | ItemAccessor<T> | undefined | - | Defines a path that returns a property of the object to use as value or a function that returns any value. See example |
legendrequired | string | - | Text content of the legend. Required. It names the set of states, which is what a screen reader announces before the first switch. See example |
legendMode | "outside" | "inside" | undefined | - | Legend rendering mode. |
legendPosition | "left" | "center" | "right" | undefined | - | Sets the text alignment of the label. |
loadingText | string | undefined | - | String displayed while items are being loaded. |
max | number | undefined | - | Maximum number of selected items. Once the cap is reached the switches that are off render disabled and the ones that are on stay live, so the user swaps rather than getting stuck. See example |
modelValuerequired | any | - | Used by v-model. Can be an array of any serializable type. |
modelValueDebounceTime | number | undefined | - | Timeout used to debounce response to changes to modelValue. |
multiple | boolean | undefined | true | Enables multi-selection behavior.
When true, v2 advertised this prop and never forwarded it: a group set to single-select still emitted an array. v3 honours it, so a model written expecting an array now receives a bare value or |
name | string | undefined | - | Defines the name of the input. |
noDataText | string | undefined | - | String displayed when there are no items to display. |
persistentHint | boolean | undefined | false | Keeps the hint displayed. |
pt | GroupPtMap<T> | undefined | - | Passthrough, object form: the same keys as the |
pt:description | PtValue | undefined | - | |
pt:description:disabled | PtValue | undefined | - | |
pt:description:errors | PtValue | undefined | - | |
pt:description:has-value | PtValue | undefined | - | |
pt:description:loading | PtValue | undefined | - | |
pt:description:readonly | PtValue | undefined | - | |
pt:description:warnings | PtValue | undefined | - | |
pt:hint | PtValue | undefined | - | |
pt:hint:disabled | PtValue | undefined | - | |
pt:hint:errors | PtValue | undefined | - | |
pt:hint:has-value | PtValue | undefined | - | |
pt:hint:loading | PtValue | undefined | - | |
pt:hint:readonly | PtValue | undefined | - | |
pt:hint:warnings | PtValue | undefined | - | |
pt:icon | PtValue | ((ctx: PtItemCtx<T, GroupPtState>) => PtItemResult) | undefined | - | |
pt:icon:checked | PtValue | undefined | - | |
pt:icon:disabled | PtValue | undefined | - | |
pt:icon:errors | PtValue | undefined | - | |
pt:icon:focus-visible | PtValue | undefined | - | |
pt:icon:focused | PtValue | undefined | - | |
pt:icon:has-value | PtValue | undefined | - | |
pt:icon:loading | PtValue | undefined | - | |
pt:icon:readonly | PtValue | undefined | - | |
pt:icon:warnings | PtValue | undefined | - | |
pt:item | PtValue | ((ctx: PtItemCtx<T, GroupPtState>) => PtItemResult) | undefined | - | |
pt:item-description | PtValue | ((ctx: PtItemCtx<T, GroupPtState>) => PtItemResult) | undefined | - | |
pt:item-description:checked | PtValue | undefined | - | |
pt:item-description:disabled | PtValue | undefined | - | |
pt:item-description:errors | PtValue | undefined | - | |
pt:item-description:focus-visible | PtValue | undefined | - | |
pt:item-description:focused | PtValue | undefined | - | |
pt:item-description:has-value | PtValue | undefined | - | |
pt:item-description:loading | PtValue | undefined | - | |
pt:item-description:readonly | PtValue | undefined | - | |
pt:item-description:warnings | PtValue | undefined | - | |
pt:item:checked | PtValue | undefined | - | |
pt:item:disabled | PtValue | undefined | - | |
pt:item:errors | PtValue | undefined | - | |
pt:item:focus-visible | PtValue | undefined | - | |
pt:item:focused | PtValue | undefined | - | |
pt:item:has-value | PtValue | undefined | - | |
pt:item:loading | PtValue | undefined | - | |
pt:item:readonly | PtValue | undefined | - | |
pt:item:warnings | PtValue | undefined | - | |
pt:label | PtValue | ((ctx: PtItemCtx<T, GroupPtState>) => PtItemResult) | undefined | - | |
pt:label:checked | PtValue | undefined | - | |
pt:label:disabled | PtValue | undefined | - | |
pt:label:errors | PtValue | undefined | - | |
pt:label:focus-visible | PtValue | undefined | - | |
pt:label:focused | PtValue | undefined | - | |
pt:label:has-value | PtValue | undefined | - | |
pt:label:loading | PtValue | undefined | - | |
pt:label:readonly | PtValue | undefined | - | |
pt:label:warnings | PtValue | undefined | - | |
pt:legend | PtValue | undefined | - | |
pt:legend:disabled | PtValue | undefined | - | |
pt:legend:errors | PtValue | undefined | - | |
pt:legend:has-value | PtValue | undefined | - | |
pt:legend:loading | PtValue | undefined | - | |
pt:legend:readonly | PtValue | undefined | - | |
pt:legend:warnings | PtValue | undefined | - | |
pt:list | PtValue | undefined | - | |
pt:list:disabled | PtValue | undefined | - | |
pt:list:errors | PtValue | undefined | - | |
pt:list:has-value | PtValue | undefined | - | |
pt:list:loading | PtValue | undefined | - | |
pt:list:readonly | PtValue | undefined | - | |
pt:list:warnings | PtValue | undefined | - | |
pt:message | PtValue | undefined | - | |
pt:message:disabled | PtValue | undefined | - | |
pt:message:errors | PtValue | undefined | - | |
pt:message:has-value | PtValue | undefined | - | |
pt:message:loading | PtValue | undefined | - | |
pt:message:readonly | PtValue | undefined | - | |
pt:message:warnings | PtValue | undefined | - | |
pt:root | PtValue | undefined | - | |
pt:root:disabled | PtValue | undefined | - | |
pt:root:errors | PtValue | undefined | - | |
pt:root:has-value | PtValue | undefined | - | |
pt:root:loading | PtValue | undefined | - | |
pt:root:readonly | PtValue | undefined | - | |
pt:root:warnings | PtValue | undefined | - | |
readonly | boolean | undefined | false | Sets the input in a readonly state. Keeps the switches focusable and submitted while swallowing changes — which is what an instant-save group holds itself in while its request is in flight. See example |
reverse | boolean | undefined | false | Reverses the layout. Applicable in every direction the order of the label and the input is swapped. |
selectable | boolean | ((item: T) => boolean) | undefined | true | Defines whether options are selectable. Can be a global boolean that affects all options or a function that accepts an item and returns a boolean that only affects that item. Non-selectable options are rendered disabled. A boolean for the group or a predicate over the item, resolving through the same per-option path as |
warnings | string | string[] | undefined | - | Warning messages to display beneath the field, in their own |
v-model
Values kept in sync through v-model.
| Name | Type | Description |
|---|---|---|
modelValue | any | The array of the options that are on, re-emitted in full on every change. An instant-save handler receives the whole next array and diffs it against the previous one; reading the single toggle off a |
Events
| Name | Type | Description |
|---|---|---|
active | (e: "active"): void | Emitted when the group becomes active (focus/click enters it). |
blur | (e: "blur", event: FocusEvent): void | Emitted when one of the generated checkbox inputs loses focus.
Forwards the original DOM |
change | (e: "change", event: Event): void | Emitted when an option is toggled.
Forwards the original DOM |
click | (e: "click", event: MouseEvent): void | Emitted when one of the generated checkbox inputs is clicked.
Forwards the original DOM |
focus | (e: "focus", event: FocusEvent): void | Emitted when one of the generated checkbox inputs receives focus.
Forwards the original DOM |
inactive | (e: "inactive"): void | Emitted when focus/click moves outside the group after it was active. Useful for validation-on-blur flows at group level. |
input | (e: "input", event: Event): void | Emitted on native input events from generated checkbox inputs.
Forwards the original DOM |
keydown | (e: "keydown", event: KeyboardEvent): void | Emitted for keyboard interaction on generated checkbox inputs.
Forwards the original DOM |
mousedown | (e: "mousedown", event: MouseEvent): void | Emitted when a pointing device button is pressed over a checkbox input.
Forwards the original DOM |
mouseup | (e: "mouseup", event: MouseEvent): void | Emitted when a pointing device button is released over a checkbox input.
Forwards the original DOM |
update:modelValue | (e: "update:modelValue", value: any): void | Emitted with the coherent next selection array whenever selection changes. Bind this together with |
Slots
The listed properties are the ones exposed to the slot scope.
| Name | Type | Description |
|---|---|---|
append | object | Content rendered after the last option, inside the options container. |
description | BbSwitchGroupDescriptionSlotProps | Replaces the description text. Provided alone (no |
icon | BbSwitchGroupIconSlotProps<T> | Replaces the default switch track visual for each option. Receives the switch state plus the source item and its display text. Replaces the entire track and thumb per option, not a glyph inside them, so the slot content has to communicate on, off and focused by itself. The input underneath keeps |
label | BbSwitchGroupLabelSlotProps<T> | Replaces the default label text for each option. |
legend | BbSwitchGroupLegendSlotProps | Replaces the default fieldset legend text for the group. |
loading | object | Content shown while options are loading (replaces the default loading text). |
no-data | object | Content shown when no options are available (replaces the default "no data" text). |
prepend | object | Content rendered before the first option, inside the options container. |
Changes from v2
Props removed or renamed in 3.0. If you are coming from v2, the answer is here.
colorremovedfails silentlyhasWarninghasWarningsfails silentlylabelPositionlegendPositionfails silently