ToggleSwitch

ToggleSwitch is used to select a boolean value.

Two-way value binding is defined using ngModel.

Two-way value binding is defined using ngModel.

basic-demo

Enabling ngModel property displays the component as active initially.

pre-selection-demo

The handle template is available to display custom content.

template-demo

When disabled is present, the element cannot be edited and focused.

disabled-demo

The invalid state is applied using the ⁠invalid property to indicate failed validation, which can be integrated with Angular Forms.

invalid-demo
template-driven-forms-demo

ToggleSwitch can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.

reactive-forms-demo

Screen Reader

InputSwitch component uses a hidden native checkbox element with switch role internally that is only visible to screen readers. Value to describe the component can either be provided via label tag combined with inputId prop or using ariaLabelledBy, ariaLabel props.

Keyboard Support

KeyFunction
tabMoves focus to the switch.
spaceToggles the checked state.
ON THIS PAGE
Theme Designer
Theme Designer is the ultimate tool to customize and design your own themes featuring a visual editor, Figma to theme code, cloud storage, and migration assistant.
Learn More