BrowseSwitch

Controls

Glass Switch

An on/off toggle whose knob turns to clear glass under your finger.

Preview

Installation

Install the package once, then import the parts you use into a standalone component.

Install

npm install ngx-vitreo @angular/cdk @floating-ui/dom
Import

import { GlassSwitch } from 'ngx-vitreo';

@Component({
  imports: [GlassSwitch],
  // ...
})

Usage

Usage

<glass-panel class="cpreview-list" variant="card">
  <div class="cpreview-list-row">
    <label [for]="id + 'notifications'">Notifications</label>
    <button
      glassSwitch
      [id]="id + 'notifications'"
      [(checked)]="notifications"
      (checkedChange)="announce('Notifications', $event)"
    ></button>
  </div>
  <div class="cpreview-list-row">
    <label [for]="id + 'autosave'">Autosave</label>
    <button
      glassSwitch
      [id]="id + 'autosave'"
      [(checked)]="autosave"
      (checkedChange)="announce('Autosave', $event)"
    ></button>
  </div>
</glass-panel>

API reference

GlassSwitch

button[glassSwitch]

InputTypeDefaultDescription
size'sm' | 'md''md'Track size.
[(checked)]booleanfalseOn state. (checkedChange) emits the next value when the user flips it.
disabledbooleanfalseStops the switch from toggling.
name / valuestring — / 'on' Submits the switch with a native form when checked.
ngModel / formControlControlValueAccessorNoneBinds the value to a template-driven or reactive form, including disabled state.