Props
| Name | Description |
|---|---|
autofocus Type: Booleanish | Focuses the field when it mounts (a dialog already open included), unless the user is typing in another field. |
checked Type: boolean | Defines the input as checked. Paints the control from state you own elsewhere and wins over |
compact Type: booleanDefaultfalse | Compact density. Swaps |
description Type: string | Text between the label and the input. Unlike the hint it is always visible; it joins the input's Always visible and tied to the control through |
disabled Type: booleanDefaultfalse | Disables the component. Takes the switch out of the tab order and out of the submitted form. Say why in |
errors Type: string | string[] | Error messages under the field, a string or array, in an |
falseValue Type: any | Value of the input when unchecked. It handles any kind of serializable object. See example |
formless Type: booleanDefaultfalse | Keep this control out of the enclosing For a switch that changes the page rather than the data, such as "Show advanced options": without it the switch joins the enclosing |
hasErrors Type: booleanDefaultfalse | Define if the component should be in an error state. It usually attaches a CSS class for styling purposes. |
hasWarnings Type: booleanDefaultfalse | Define if the component should be in a warning state. Same chrome as errors with |
hideLabel Type: booleanDefaultfalse | Visually hides the label of the input while maintaining accessibility. |
hint Type: string | Text box to be displayed near the input, usually to indicate instructions. |
id Type: string | The |
indeterminate Type: booleanDefaultfalse | Sets the input in an indeterminate state. Parks the thumb midway, for a master switch whose children disagree. Visual only: the model keeps its value, and the component re-asserts the state after clicks because the DOM resets it natively. See example |
inputAlign Type: FieldCrossAlign | Vertical position of the control in a side-by-side row; not |
inputPosition Type: "left" | "center" | "right"Default"left" | Sets the alignment of the input. Since inputs are inline block they can be aligned just as text can. |
label requiredType: string | Text content of the label of the element. Required: it is the accessible name of the switch. Do not add ARIA of your own: the control already exposes |
labelAlign Type: FieldCrossAlign | Vertical position of the label block in a side-by-side row; not |
labelPosition Type: "left" | "center" | "right" | Sets the text alignment of the label. |
layout Type: Responsive<FieldLayout>Default"auto" | How label and input sit together: The settings row is |
modelValue Type: any | Used by v-model. Can be any serializable type. |
name Type: string | Defines the name of the input. |
persistentHint Type: booleanDefaultfalse | Keeps the hint displayed. |
pt Type: PtMap<TogglePtPart, CheckablePtState> | Passthrough, object form: the same keys as the |
pt:<part> Type: PtValue | Passthrough, attribute form: one attribute per part, |
readonly Type: booleanDefaultfalse | Sets the input in a readonly state. The right state for a switch whose change is in flight, and for admin-locked settings. It sets no native |
required Type: booleanDefaultfalse | Sets the input as required. |
reverse Type: booleanDefaultfalse | 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 a v2 |
rules Type: RuleExpression<any> | vee-validate rules for this field. Only inside a |
submitWhenFalse Type: booleanDefaultfalse | Will submit "falseValue" if the input is not checked. Otherwise "trueValue" will be submitted. Only for classic form posts: an unchecked switch otherwise submits nothing. The full value contract is shared with |
trueValue Type: any | Value of the input when checked. It handles any kind of serializable object. Point it and |
validationLabel Type: string | The field's name in validation messages ( |
validationMode Type: ValidationMode | When the field validates: |
warnings Type: string | string[] | Warning messages under the field, a string or array: amber, in their own |
v-model
Values kept in sync through v-model.
| Name | Description |
|---|---|
modelValue Type: any | Carries the mapped |
Events
| Name | Description |
|---|---|
blur Type: (event: FocusEvent): void | Emitted when the native input loses focus. Forwards the original DOM |
change Type: (event: Event): void | Emitted when the switch checked state changes. Forwards the original DOM |
click Type: (event: MouseEvent): void | Emitted when the input receives a click interaction. Forwards the original DOM |
focus Type: (event: FocusEvent): void | Emitted when the native input gains focus. Forwards the original DOM |
input Type: (event: Event): void | Emitted on native input events from the switch input. Forwards the original DOM |
keydown Type: (event: KeyboardEvent): void | Emitted for keyboard interaction on the input. Forwards the original DOM |
mousedown Type: (event: MouseEvent): void | Emitted when a pointing device button is pressed over the input. Forwards the original DOM |
mouseup Type: (event: MouseEvent): void | Emitted when a pointing device button is released over the input. Forwards the original DOM |
update:modelValue Type: (value: any): void | Emitted on checked-state changes with the effective model value:
- The hook for a live switch that saves itself: write optimistically here, hold the control readonly while the request is in progress, and restore the previous value on failure. See example |
Slots
The listed properties are the ones exposed to the slot scope.
| Name | Description |
|---|---|
description Type: BbSwitchDescriptionSlotProps | Replaces the description text. Provided alone (no |
icon Type: BbCheckboxIconSlotProps | Replaces the default toggle track visual inside the switch. Receives the switch state plus the label text. Replaces the entire track and thumb, not a glyph inside them: a bare icon here leaves no track at all. Keep it when only the visual is wrong; when the whole row is wrong, drop to |
label Type: BbSwitchLabelSlotProps | Replaces the default label text rendered next to the switch. |
Renamed and removed
Names from v2 and from earlier 3.0 betas that no longer work, and what to write instead.
colorremovedfails silentlydirectionlayoutfails silentlyhasWarninghasWarningsfails silentlyvalidateOnvalidationModefails silentlyAn array of events became one mode (
aggressive|balanced|lazy|submit-only|submit-live). The old defaults (['blur'],['inactive'], a toggle's['update:modelValue', 'change', 'blur']) arebalanced, the new default: delete the prop. A text field on['update:modelValue']isvalidation-mode="aggressive". Set it once on<BbForm validation-mode>instead of per field.vidremovedfails silentlyA display name (v2:
vid="Email address") is nowvalidation-label; a field path (3.0 betas:vid="address.city") is nowname(brackets for a native post:address[city]).check --fixpicks by the value.