Toggle

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

Installation

ng g @spartan-ng/cli:ui toggle

Usage

import { HlmToggleImports } from '@spartan-ng/helm/toggle';
<button hlmToggle>Toggle</button>

Examples

Outline

With Text

Size

Disabled

RTL

To enable RTL support in spartan-ng, see the RTL configuration guide.

Brain API

BrnToggle

Selector: button[brnToggle]

Inputs

PropTypeDefaultDescription
id string `brn-toggle-${++BrnToggle._uniqueId}` The id of the toggle.
value T - The value this toggle represents.
disabled boolean false Whether the toggle is disabled.
type 'button' | 'submit' | 'reset' 'button' The type of the button.
aria-label string | null null Accessibility label for screen readers. Use when no visible label exists.
state 'on' | 'off' 'off' The current state of the toggle when not used in a group.

Outputs

PropTypeDefaultDescription
stateChange 'on' | 'off' 'off' The current state of the toggle when not used in a group.

Helm API

HlmToggle

Selector: button[hlmToggle]

Inputs

PropTypeDefaultDescription
variant ToggleVariants['variant'] 'default' -
size ToggleVariants['size'] 'default' -
id string `brn-toggle-${++BrnToggle._uniqueId}` The id of the toggle.
value T - The value this toggle represents.
disabled boolean false Whether the toggle is disabled.
state 'on' | 'off' 'off' The current state of the toggle when not used in a group.
aria-label string | null null Accessibility label for screen readers. Use when no visible label exists.
type 'button' | 'submit' | 'reset' 'button' The type of the button.

Outputs

PropTypeDefaultDescription
stateChange 'on' | 'off' - The current state of the toggle when not used in a group.
Toggle Group Textarea