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/domImport
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]
| Input | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'md' | Track size. |
[(checked)] | boolean | false | On state. (checkedChange) emits the next value when the user flips it. |
disabled | boolean | false | Stops the switch from toggling. |
name / value | string | — / 'on' | Submits the switch with a native form when checked. |
ngModel / formControl | ControlValueAccessor | None | Binds the value to a template-driven or reactive form, including disabled state. |