Skip to content

BbCheckboxGroup

Several boxes inside one set, with your data as the options and one array as the model.

import { BbCheckboxGroup } from 'bitboss-ui';

On this page

Use it for

Reach for BbCheckboxGroup when the answer is several choices out of one set: which teams get the alert, which scopes the token carries. You hand it your rows, it renders one box per row.

Use something else when

  • BbCheckbox: it is one yes/no standing alone
  • BbRadioGroup: exactly one choice out of the set
  • BbSwitchGroup: they are on/off states, not answers
  • BbSelect: the set is long, searchable or paged. Forty checkboxes are a scroll, not a control

Pass Through

Hover or tap a part to outline it. Toggles flip loading, errors and warnings when the component has them — only parts highlight.

Shown under the label — durable context.
Guidance while the control is focused.

Do not hand-stack BbCheckbox. The group adds a fieldset, shared validation, item mapping, and selection limits.

Options from your data

Pass your domain objects as they are, and name the two fields that matter: the one the user reads, and the one you want in the model.

Notify on failed deploysThey get an email whenever a deploy fails.

Model: [2, 5]

Use item-text and item-value for objects. Prefer a unique primitive id for item-value; duplicate values are dropped silently.

The default model is an array. For one exclusive value, use BbRadioGroup instead of :multiple="false".

The fieldset and the legend

The group renders a real <fieldset> with a real <legend>, which is what makes the boxes one thing rather than several.

Newsletter sectionsSent on the first Monday of every month.
Newsletter sections

legend is required and names the set for assistive technology. Use hide-legend when a nearby heading already shows the same name. hide-label instead hides every option label.

The group takes one description and one hint. Use separate checkboxes when individual options need different explanations.

Locked options

An option that exists but cannot be chosen is a predicate over the item, not a flag inside it.

On-call rotationDeactivated members cannot take a shift.

1 on the rotation

selectable locks all options or selected items through a predicate. Rejected options stay visible and disabled.

Migrating from v2: a disabled field on the item object now does nothing. v2's groups honoured it and warned; v3 treats it as ordinary domain data and ignores it silently. Options that used to render locked become tickable. Grep the code that builds your items for disabled: and move each one into selectable:

diff
- :items="channels.map((c) => ({ ...c, disabled: !c.configured }))"
+ :items="channels"
+ :selectable="(c) => c.configured"

readonly keeps values focusable and submitted while blocking changes. disabled currently leaves selected options removable, so use readonly to freeze a populated group.

Capping the selection

max is the cap on how many options may be on at once.

Topics in your digestPick up to three. Untick one to make room for another.

2 of 3 selected

At the cap, unchecked options disable while checked ones stay removable. State the limit in description and show a count; the component renders neither.

Validating the whole set

There is no required prop here. "At least one" is an application rule, so it lives in the one errors channel the fieldset already has.

Teams this alert reaches

Submit with nothing ticked to see the message.

One errors message covers the set. There is no required prop; validate the array when at least one choice is mandatory.

Inside a validated form, import the group from bitboss-ui/validated and give it rules. The array is validated as a single field, and the field's name comes from legend.

vue
<BbCheckboxGroup
    v-model="scopes"
    :items="available"
    legend="Token scopes"
    rules="required"
/>

validate-on defaults to ['inactive'], after focus leaves the group.

When the options change

Give items a function instead of an array and the group loads its own options. dependencies says what makes it load them again.

Country
Distribution hubs

Model: [milan]

The provider runs on mount and when dependencies change. deps-debounce-time groups rapid changes. Add enforce-coherence when stale selections must be removed after options reload.

Decorating an option

The label slot replaces the text of every option, and receives enough to decide what each one looks like.

Items in the starter bundle

1 items in the bundle

The scope is { item, text, checked }. Keep text in the rendered label so the option retains an accessible name. Use separate checkboxes when only one option needs unique markup.

Coming from v2

#option:prepend and #option:append are gone. Everything they did moves into #label, which can put content on either side of the text. Note that #prepend and #append still exist and are unrelated. Those inject once into the options container, before the first option and after the last.

Layout and CSS

input-direction arranges options. direction arranges the legend and options.

Teams in the report
Teams in the report

input-direction="vertical" stacks options. Use direction, alignment props, reverse, and compact for the outer fieldset layout.

Coming from v2

labelPosition is now legendPosition. It is a plain rename with no behaviour change, and it is silent: an unknown attribute falls through to the DOM, so the alignment stops applying.

The other v3 change here is bigger and just as quiet. In v2 one CSS block, bb-cr-container, served all three groups, so a rule written for checkboxes hit radios too. Each group now has its own block, with otherwise identical suffixes:

v2v3
.bb-cr-container.bb-base-checkbox-group, .bb-base-radio-group, .bb-base-switch-group
.bb-cr-container--horizontal.bb-base-…-group--horizontal
.bb-cr-container--vertical.bb-base-…-group--vertical
.bb-cr-container--errors.bb-base-…-group--errors
.bb-cr-container__container.bb-base-…-group__container
.bb-cr-container__loading-container.bb-base-…-group__loading-container
.bb-cr-container__no-data-container.bb-base-…-group__no-data-container
.bb-cr-container-option.bb-base-…-group-option
.bb-cr-container-option__text.bb-base-…-group-option__text
.bb-base-…-group--warnings and .bb-base-…-group-option--selected, both new

Nothing in v3 renders bb-cr-container. Search styles and test selectors, then list all three new blocks where a rule applies to every group.

css
.bb-base-checkbox-group-option__text,
.bb-base-radio-group-option__text,
.bb-base-switch-group-option__text {
    font-weight: 500;
}

For control colors and geometry, use the box variables documented on BbCheckbox.