# Checkbox
### Install
``` javascript
import { Checkbox, CheckboxGroup } from 'vant';
Vue.use(Checkbox).use(CheckboxGroup);
```
## Usage
### Basic Usage
```html
Checkbox
```
```javascript
export default {
data() {
return {
checked: true
};
}
};
```
### Disabled
```html
Checkbox
```
### Custom Color
```html
Checkbox
```
### Custom Icon
Use icon slot to custom icon
```html
Custom Icon
```
```js
export default {
data() {
checked: true,
icon: {
normal: '//img.yzcdn.cn/icon-normal.png',
active: '//img.yzcdn.cn/icon-active.png'
}
}
}
```
### Checkbox Group
When Checkboxes are inside a CheckboxGroup, the checked checkboxes's name is an array and bound with CheckboxGroup by v-model.
```html
Checkbox {{ item }}
```
```javascript
export default {
data() {
return {
list: ['a', 'b', 'c'],
result: ['a', 'b']
};
}
};
```
### Maximum amount of checked options
```html
Checkbox {{ item }}
```
### Inside a Cell
```html
```
```js
export default {
methods: {
toggle(index) {
this.$refs.checkboxes[index].toggle();
}
}
}
```
## API
### Checkbox Props
| Attribute | Description | Type | Default |
|------|------|------|------|
| name | Checkbox name | `any` | - |
| shape | Can be set to `square` | `String` | `round` |
| v-model | Check status | `Boolean` | `false` |
| disabled | Diable checkbox | `Boolean` | `false` |
| icon-size | Icon size | `String | Number` | `20px` |
| label-disabled | Whether to disable label click | `Boolean` | `false` |
| label-position | Can be set to `left` | `String` | `right` |
| checked-color | Checked color | `String` | `#1989fa` | - |
### CheckboxGroup Props
| Attribute | Description | Type | Default |
|------|------|------|------|
| v-model | Names of all checked checkboxes | `Array` | - |
| disabled | Disable all checkboxes | `Boolean` | `false` |
| max | Maximum amount of checked options | `Number` | `0`(Unlimited) |
### Checkbox Events
| Event | Description | Parameters |
|------|------|------|
| change | Triggered when value changed | current value |
| click | Triggered when click checkbox | event: Event |
### CheckboxGroup Events
| Event | Description | Parameters |
|------|------|------|
| change | Triggered when value changed | current value |
### Checkbox Slots
| Name | Description | slot-scope |
|------|------|------|
| default | Custom label | - |
| icon | Custom icon | checked: whether to be checked |
### Checkbox Methods
Use ref to get checkbox instance and call instance methods
| Name | Attribute | Return value | Description |
|------|------|------|------|
| toggle | - | - | Toggle check status |