Toggle

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

Installation

npx nx g @spartan-ng/cli:ui toggle

Usage

import { HlmToggleDirective } from '@spartan-ng/helm/toggle';
import { BrnToggleDirective } from '@spartan-ng/brain/toggle';
<button brnToggle hlm>
  <ng-icon hlm size="sm" name="lucideItalic" />
</button>

Brain API

BrnToggle

Selector: button[hlmToggle], button[brnToggle]

Inputs

PropTypeDefaultDescription
id unknown `brn-toggle-${BrnToggle._uniqueId++}` The id of the toggle.
value T - The value this toggle represents.
disabled boolean false Whether the toggle is disabled.
disableToggleClick boolean false Whether the toggle is responds to click events.
state 'on' | 'off' off The current state of the toggle when not used in a group.

Outputs

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

Helm API

HlmToggle

Selector: [hlmToggle],[brnToggle][hlm]

Inputs

PropTypeDefaultDescription
variant ToggleVariants['variant'] default -
size ToggleVariants['size'] default -
class ClassValue --

Examples

Outline

With Text

Small

Large

Disabled

Toggle Group Textarea