Checkbox

Collect user's choices.
Import

When To Use#

  • Used for selecting multiple values from several options.
  • If you use only one checkbox, it is the same as using Switch to toggle between two states. The difference is that Switch will trigger the state change directly, but Checkbox just marks the state as changed and this needs to be submitted.

Examples

Basic usage of checkbox.

      Loading...
    


Communicated with other components.

      Loading...
    

The nzIndeterminate property can help you to achieve a 'check all' effect.

      Loading...
    

We can use nz-checkbox and Grid in nz-checkbox-wrapper, to implement complex layout.

⚠️ nz-checkbox-wrapper is deprecated, we recommend using nz-checkbox-group.

      Loading...
    

Disabled checkbox.

      Loading...
    




Generate a group of checkboxes from an array.

      Loading...
    

We can use nz-checkbox and Grid in nz-checkbox-group, to implement complex layout.

      Loading...
    

API#

[nz-checkbox]#

PropertyDescriptionTypeDefault
[nzId]input id attribute inside the componentstring-
[nzName]input name attribute inside the componentstring-
[nzAutoFocus]get focus when component mountedbooleanfalse
[nzDisabled]Disable checkboxbooleanfalse
[ngModel]Specifies whether the checkbox is selected, double bindingbooleanfalse
[nzIndeterminate]set the status of indeterminate,only affect the stylebooleanfalse
[nzValue]use for the callback of nz-checkbox-wrapperany-
(ngModelChange)The callback function that is triggered when the state changes.EventEmitter<boolean>-

nz-checkbox-group#

PropertyDescriptionTypeDefault
[ngModel]Specifies options, double bindingstring[] | number[][]
[nzName]The name property of all input childrenstring-
[nzOptions]Specifies optionsstring[] | number[] | NzCheckboxOption[][]
[nzDisabled]Disable all checkboxesbooleanfalse
(ngModelChange)The callback function that is triggered when the state changes.EventEmitter<string[] | number[]>-

nz-checkbox-wrapper#

PropertyDescriptionTypeDefault
(nzOnChange)The callback function that is triggered when the state changes.EventEmitter<any[]>-

Methods#

[nz-checkbox]#

NameDescription
focus()get focus
blur()remove focus

Interfaces#

NzCheckboxOption#

export interface NzCheckboxOption {
  label: string;
  value: string | number;
  disabled?: boolean;
}