Toggle

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

PreviousNext

Installation

1

Run the CLI

Use the CLI to add the component to your project.

npx @ngzard/ui@latest add toggle

Examples

default

with forms

with default

outline

with text

small

large

disabled

API

[z-toggle] Component

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

Properties

Property Description Type Default
[class] Custom CSS classes string ''
[zSize] Toggle size 'sm' | 'md' | 'lg' 'md'
[zType] Visual style 'default' | 'outline' 'default'
[zValue] Toggle value boolean undefined
[zDefault] Default value when uncontrolled (used as initial state only) boolean false
[disabled] Disables the toggle (also integrates with Angular Forms) boolean false
[aria-label] Accessible label for screen readers (required when using icons only) string ''

Events

Event Description Payload
(zToggleClick) Emitted when the toggle is clicked void
(zToggleHover) Emitted when the toggle is hovered void
(zToggleChange) Emitted when the toggle value changes boolean