Skip to content

Checkbox ​

Brief Introduction ​

The checkbox component is used for users to select one or more options from multiple choices. mengyue-components has encapsulated it and performed vitest testing. There are two ways to implement checkbox tags: <MYCheckbox /> or <MYCheckbox></MYCheckbox><MYCheckbox-group /> or <MYCheckbox-group></MYCheckbox-group> for checkbox groups.

Basic Usage ​

Single Checkbox ​

Use modelValue to bind the value of a single checkbox.

Code Demo
展开代码

Checkbox Group ​

Use <MYCheckbox-group></MYCheckbox-group> to group checkboxes together.

Code Demo
展开代码

Layout Direction ​

Vertical Arrangement ​

Use direction="vertical" to arrange checkboxes vertically.

Code Demo
展开代码

Disabled State ​

Disable Entire Group ​

Disable the entire checkbox group.

Code Demo
展开代码

Custom Spacing ​

Use the gap property to control the spacing between checkboxes.

Code Demo
展开代码

API Reference ​

MYCheckboxGroup Props ​

ParameterDescriptionTypeOptionsDefault
modelValueBound valuearray—[]
directionLayout directionstringhorizontal / verticalhorizontal
disabledWhether disabledboolean—false
gapSpacingstringSupports CSS units12px

MYCheckbox Props ​

ParameterDescriptionTypeOptionsDefault
modelValueBound valueboolean—false
valueOption valuestring | number——
disabledWhether disabledboolean—false

Type Definitions ​

typescript
interface CheckboxGroupProps {
  modelValue?: (string | number)[];
  direction?: 'horizontal' | 'vertical';
  disabled?: boolean;
  gap?: string;
}

interface CheckboxProps {
  modelValue?: boolean;
  value?: string | number;
  disabled?: boolean;
}

Released under the MIT License.