Switch
A control that allows the user to toggle between checked and not checked.
Preview
A preview of the Switch component with interactive controls.
Interactive
Installation
Add the Switch component to your project.
ng g @ng-cn/core:c switchUsage
Import and use the Switch component in your Angular application.
<div class="flex items-center space-x-2">
<Switch id="airplane-mode" [(checked)]="enabled" />
<Label htmlFor="airplane-mode">Airplane Mode</Label>
</div>Examples
Explore different variations and use cases for the Switch component.
Basic
Interactive
API Reference
Props | Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | false | Whether the switch is checked. |
disabled | boolean | false | Whether the switch is disabled. |
id | string | — | The id of the switch. |