Skip to content

BbCheckbox

Toggles a single boolean option.

import { BbCheckbox } from 'bitboss-ui';

On this page

Props

NameTypeDefaultDescription
autofocusBooleanish | undefined-

Sets autofocus on page load.

checkedboolean | undefined-

Defines the input as checked.

Overrides the model-derived display, so it is how a select-all master paints itself from its children. Passing it together with a v-model gives the box two sources of truth and checked wins — pick one. Narrowed to a plain boolean in v3: the v2 checked="false" no longer compiles, which is the loud version of a bug that used to check the box.

See example
descriptionstring | 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 aria-describedby (after any errors / warnings, before the hint).

Always visible, unlike hint. Put durable information here — including the reason a box is disabled, which otherwise reads as a bug.

See example
directionInputDirection | undefined"auto"

Direction of the layout of the component. Can either be a predefined value or a pattern separated by a space like xx xxxxx.

A two-token pattern such as "x xxxxxxx" splits the width by token length, the first token sizing whichever element renders first — which reverse decides.

See example
disabledboolean | undefinedfalse

Disables the component.

Takes the box out of the tab order and out of the form post. When the value must still reach the server, you want readonly instead.

See example
errorsstring | string[] | undefined-

Can be a string or an array of string containing the messages to display. They render in an aria-live="polite" region (announced when they appear) and, while the list is non-empty, are referenced FIRST from the control's aria-describedby, so the reason the field is invalid is re-read whenever the control regains focus.

A non-empty value puts the field in the error state by itself; has-errors is for the styling without a message. Referenced first from aria-describedby, so it is what a screen reader reads when the field regains focus.

See example
falseValueany-

Value of the input when unchecked. It handles any kind of serializable object.

See example
hasErrorsboolean | undefinedfalse

Define if the component should be in an error state. It usually attaches a CSS class for styling purposes.

See example
hasWarningsboolean | undefinedfalse

Define if the component should be in a warning state. Same chrome as errors with --bb-warn; errors take priority.

See example
hideLabelboolean | undefinedfalse

Visually hides the label of the input while maintaining accessibility.

For dense composites where visible text already labels the box — a selection column in a table. It hides the label, it does not remove it: label is still required.

See example
hintstring | undefined-

Text box to be displayed near the input, usually to indicate instructions.

Hidden until the field has focus unless persistent-hint pins it open. Guidance for the moment of filling in; anything durable belongs in description.

See example
idstring | undefined-

The identifier of the component.

indeterminateboolean | undefinedfalse

Sets the input in an indeterminate state.

Visual only — it never enters the model, and the component re-applies it after a click because the native state resets on interaction. If the server needs a real tri-state value, model it explicitly.

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.

See example
labelrequiredstring-

Text content of the label of the element.

Required, because it is the accessible name. It stays required when you replace the rendered text through the label slot — the slot decorates the string, it does not replace its role.

See example
labelPosition"left" | "center" | "right" | undefined-

Sets the text alignment of the label.

modelValueany-

Used by v-model. Can be any serializable type.

namestring | undefined-

Defines the name of the input.

Generated when omitted, which is fine in an SPA and not in a form that posts. Pass it whenever the value has to arrive under a known key.

See example
persistentHintboolean | undefinedfalse

Keeps the hint displayed.

See example
ptPtMap<TogglePtPart, CheckablePtState> | undefined-

Passthrough, object form: the same keys as the pt:* attributes without the prefix. See the pt:<part> row.

pt:descriptionPtValue | undefined-
pt:description:checkedPtValue | undefined-
pt:description:disabledPtValue | undefined-
pt:description:errorsPtValue | undefined-
pt:description:focus-visiblePtValue | undefined-
pt:description:focusedPtValue | undefined-
pt:description:indeterminatePtValue | undefined-
pt:description:readonlyPtValue | undefined-
pt:description:warningsPtValue | undefined-
pt:hintPtValue | undefined-
pt:hint:checkedPtValue | undefined-
pt:hint:disabledPtValue | undefined-
pt:hint:errorsPtValue | undefined-
pt:hint:focus-visiblePtValue | undefined-
pt:hint:focusedPtValue | undefined-
pt:hint:indeterminatePtValue | undefined-
pt:hint:readonlyPtValue | undefined-
pt:hint:warningsPtValue | undefined-
pt:iconPtValue | undefined-
pt:icon:checkedPtValue | undefined-
pt:icon:disabledPtValue | undefined-
pt:icon:errorsPtValue | undefined-
pt:icon:focus-visiblePtValue | undefined-
pt:icon:focusedPtValue | undefined-
pt:icon:indeterminatePtValue | undefined-
pt:icon:readonlyPtValue | undefined-
pt:icon:warningsPtValue | undefined-
pt:labelPtValue | undefined-
pt:label:checkedPtValue | undefined-
pt:label:disabledPtValue | undefined-
pt:label:errorsPtValue | undefined-
pt:label:focus-visiblePtValue | undefined-
pt:label:focusedPtValue | undefined-
pt:label:indeterminatePtValue | undefined-
pt:label:readonlyPtValue | undefined-
pt:label:warningsPtValue | undefined-
pt:messagePtValue | undefined-
pt:message:checkedPtValue | undefined-
pt:message:disabledPtValue | undefined-
pt:message:errorsPtValue | undefined-
pt:message:focus-visiblePtValue | undefined-
pt:message:focusedPtValue | undefined-
pt:message:indeterminatePtValue | undefined-
pt:message:readonlyPtValue | undefined-
pt:message:warningsPtValue | undefined-
pt:rootPtValue | undefined-
pt:root:checkedPtValue | undefined-
pt:root:disabledPtValue | undefined-
pt:root:errorsPtValue | undefined-
pt:root:focus-visiblePtValue | undefined-
pt:root:focusedPtValue | undefined-
pt:root:indeterminatePtValue | undefined-
pt:root:readonlyPtValue | undefined-
pt:root:warningsPtValue | undefined-
readonlyboolean | undefinedfalse

Sets the input in a readonly state.

Not the same as disabled: it sets no native attribute, so the box stays focusable and still submits, while every change is swallowed and update:modelValue never fires. Use it for a value the user may see and must not change.

See example
requiredboolean | undefinedfalse

Sets the input as required.

Sets the native attribute, so the box joins native form validation. For app-driven validation prefer errors, where you control the wording and the announcement.

See example
reverseboolean | undefinedfalse

Reverses the layout: in every direction the order of the label and the input is swapped from the standard arrangement.

Its meaning inverted in v3 and the compiler cannot see it. The default rendering is unchanged, but :reverse="false" from v2 becomes a bare reverse, and a v2 reverse is simply deleted.

See example
submitWhenFalseboolean | undefinedfalse

Will submit "falseValue" if the input is not checked. Otherwise "trueValue" will be submitted.

An unchecked box posts nothing at all — standard HTML, and a recurring surprise on the server. This renders a hidden input carrying false-value so the field always arrives. Irrelevant in an SPA, where you bind into form state instead.

See example
trueValueany-

Value of the input when checked. It handles any kind of serializable object.

Checked-ness is derived by deep equality against this value, so object values match structurally rather than by reference.

See example
warningsstring | string[] | undefined-

Warning messages to display beneath the field, in their own aria-live region and amber (--bb-text-warn). A string or array; a non-empty list implies the warning state. Errors suppress warnings when both are set. While displayed they are also referenced from the control's aria-describedby, after any errors and before the description/hint.

The amber counterpart of errors, for a value that is valid but worth a second look. It does not set aria-invalid, and errors suppress it when both are set.

See example

v-model

Values kept in sync through v-model.

NameTypeDescription
modelValueany

Carries true-value on check and false-value on uncheck, and nothing else. Never derive the state from a @click or @change handler; those are for side concerns.

See example

Events

NameTypeDescription
blur(event: "blur", event: FocusEvent): void
change(event: "change", event: Event): void
click(event: "click", event: MouseEvent): void
focus(event: "focus", event: FocusEvent): void
input(event: "input", event: Event): void
keydown(event: "keydown", event: KeyboardEvent): void
mousedown(event: "mousedown", event: MouseEvent): void
mouseup(event: "mouseup", event: MouseEvent): void
update:modelValue(event: "update:modelValue", value: any): void

Slots

The listed properties are the ones exposed to the slot scope.

NameTypeDescription
descriptionBbCheckboxDescriptionSlotProps

Replaces the description text. Provided alone (no description prop) it still renders the description region and wires it into aria-describedby.

iconBbCheckboxIconSlotProps

Replaces the default checkmark SVG inside the checkbox box. Receives the checkbox state plus the label text.

Replaces the entire box visual — border, background and checkmark — so the slot content has to communicate every state itself. When the row around it is the problem rather than the box, drop to BbBaseCheckboxIcon instead.

See example
labelBbCheckboxLabelSlotProps

Replaces the default label text rendered next to the checkbox.

Receives { text, hasErrors, hasWarnings }. The whole control is one <label>, so interactive children have to be real anchors: a click on an <a> navigates, a click on anything else toggles the box.

See example

Changes from v2

Props removed or renamed in 3.0. If you are coming from v2, the answer is here.

  • colorremovedfails silently
  • hasWarninghasWarningsfails silently