form

Toggle

A two-state button that can be either on or off.

Preview

A preview of the Toggle component with interactive controls.

Preview Code
Interactive

Installation

Add the Toggle component to your project.

Bash
ng g @ng-cn/core:c toggle

Usage

Import and use the Toggle component in your Angular application.

Template TypeScript
template.html
<Toggle aria-label="Toggle bold">
  <lucide-icon name="bold" class="h-4 w-4" />
</Toggle>

Examples

Explore different variations and use cases for the Toggle component.

Basic

Preview Code
Interactive

With Text

Preview Code
Interactive

Outline

Preview Code
Interactive

API Reference

Props
Prop Type Default Description
variant 'default' | 'outline' 'default' The visual style of the toggle.
size 'default' | 'sm' | 'lg' 'default' The size of the toggle.
pressed boolean false Whether the toggle is pressed.