Checkbox
Usage
Checkbox is an independent on or off control for boolean values and multi-select lists. Use it when users can turn an option on or off without affecting other options, when multiple options in a group can be selected at the same time, or for form fields that should submit a boolean value.
import { MtCheckbox } from "@shopware-ag/meteor-component-library";
Examples
States
API reference
Props
| Prop | Type | Default |
|---|---|---|
nameThe name of the input field when submitting a form. | string | undefined |
map-inheritance | Record<string, any> | null |
errorError object for this field. | Record<string, any> | null |
labelA label for the checkbox. | string | undefined |
requiredMarks the field as required with an asterix. | boolean | false |
is-inheritedDetermines if the field is inherited. | boolean | false |
help-textHelp text with additional information for the field. | string | null |
disabledToggles the disabled state of the checkbox. | boolean | false |
model-valuev-model binding for the checkbox value. | boolean | undefined |
checkedDetermines the checked state of the checkbox. | boolean | undefined |
partialDetermines if the field is partially checked. | boolean | false |
inherited-valueInherited value from another SalesChannel. | boolean | null |
borderedDetermines if the field is surrounded by a border. | boolean | false |
on-update:model-value | ((...args: any[]) => any) | undefined | |
on-change | ((...args: any[]) => any) | undefined | |
on-inheritance-remove | ((...args: any[]) => any) | undefined | |
on-inheritance-restore | ((...args: any[]) => any) | undefined | |
on-update:checked | ((...args: any[]) => any) | undefined |
Exposed
| Name | Type |
|---|---|
checkboxClasses | { "mt-switch--future-remove-default-margin": any; } |
id | string |
currentValue | boolean |
formFieldName | string |
MtCheckboxFieldClasses | { "has--error": boolean; "is--disabled": boolean; "is--inherited": boolean; "is--bordered": boolean; "is--partly-checked": boolean; } |
identification | string |
hasError | boolean |
inputState | boolean |
isInheritanceField | boolean |
isInheritedComputed | boolean |
isDisabled | boolean |
isPartlyChecked | boolean |
iconName | string |
Best practices
Do
- Use short, clear labels that describe the checked state in plain language.
- Use help text when the effect of the option is not obvious from the label alone.
- Use the indeterminate state only when the checkbox represents a mixed selection.
Don't
- Do not use Checkbox for mutually exclusive options.
- Do not use the indeterminate state as a permanent third value.
- Do not rely on the checkmark alone without a visible label.
Behavior
- Prefer
v-modelwithmodelValueandupdate:modelValuefor new code. Thecheckedprop andchangeevent are legacy APIs. partialshows an indeterminate visual state. It is useful for parent selections with mixed child states.inheritedValueandisInheritedsupport inheritance fields. An inherited Checkbox is disabled until inheritance is removed.helpText,error,required, andborderedintegrate with the shared field wrapper.
Accessibility
- Always provide a visible label, either through the
labelprop or thelabelslot. - Checkbox uses a native checkbox input, so it supports standard keyboard interaction such as toggling with the Space key.
- If the indeterminate state needs explanation, describe its meaning in nearby text instead of relying on the visual state alone.
Related components
- Radio Group: when users must choose exactly one option from a small set of visible choices.
- Select: when users need to choose from a longer list or when space is limited.