category | type | title | cover |
---|---|---|---|
Components |
Data Entry |
Switch |
Switching Selector.
- If you need to represent the switching between two states or on-off state.
- The difference between
Switch
andCheckbox
is thatSwitch
will trigger a state change directly when you toggle it, whileCheckbox
is generally used for state marking, which should work in conjunction with submit operation.
import { NzSwitchModule } from 'ng-zorro-antd/switch';
Property | Description | Type | Default | Global Config |
---|---|---|---|---|
[nzId] |
button id attribute inside the component | string |
- | |
[ngModel] |
determine whether the nz-switch is checked, double binding |
boolean |
false |
|
[nzCheckedChildren] |
content to be shown when the state is checked | string | TemplateRef<void> |
- | |
[nzUnCheckedChildren] |
content to be shown when the state is unchecked | string | TemplateRef<void> |
- | |
[nzDisabled] |
Disable switch | boolean |
false |
|
[nzSize] |
the size of the nz-switch , options: default small |
'small' | 'default' |
'default' |
✅ |
[nzLoading] |
loading state of switch | boolean |
false |
|
[nzControl] |
determine whether fully control state by user | boolean |
false |
|
(ngModelChange) |
a callback function, can be executed when the checked state is changing | EventEmitter<boolean> |
- |
Name | Description |
---|---|
focus() | get focus |
blur() | remove focus |