Component
Switch
A toggle for a single on/off setting. Bind the checked state, add a label on either side, put icons in the thumb, size and colour it, and swap the plain switch for a selectable card. Works with forms.
Label, position & icons
notify: true
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { HbSwitchImports } from '@herbst/ui';
import { provideIcons } from '@ng-icons/core';
import { phosphorCheck, phosphorX } from '@ng-icons/phosphor-icons/regular';
@Component({
selector: 'hb-demo-switch-basic',
imports: [HbSwitchImports],
viewProviders: [provideIcons({ phosphorCheck, phosphorX })],
template: `
<div class="flex flex-col items-start gap-3">
<hb-switch [(hbChecked)]="notify" hbCheckedIcon="phosphorCheck" hbUncheckedIcon="phosphorX">
Email notifications
</hb-switch>
<hb-switch [hbChecked]="true" hbLabelPosition="start">Label at the start</hb-switch>
<p class="font-mono text-[12px] text-muted-foreground">notify: {{ notify() }}</p>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HbDemoSwitchBasicComponent {
protected readonly notify = signal(true);
}
Sizes, status & disabled
Switch cards
API reference
hb-switch
| Property | Description | Type | Default |
|---|---|---|---|
| [(hbChecked)] | The on/off state, two-way bound. Also works as a form control via ngModel / formControl. | boolean | false |
| [hbLabelPosition] | Which side the projected label sits on. | 'start' | 'end' | 'end' |
| [hbCheckedIcon] / [hbUncheckedIcon] | Icon names shown inside the thumb for each state. | string | '' |
| [hbSize] / [hbStatus] | Switch dimensions, and the checked colour. | 'xs'–'xl' / 'default' | 'success' | 'warning' | 'error' | 'md' / 'default' |
| [hbDisabled] / [hbInvalid] / [hbRequired] | Standard control states forwarded to the input and ARIA. | boolean | false |
| [hbName] / [hbInputId] / [hbAriaLabel] / (hbChange) | Form name, input id, accessible label, and an event with the new state. | string / boolean | '' |
hb-switch-card
| Property | Description | Type | Default |
|---|---|---|---|
| hb-switch-card | A card variant that projects rich content and toggles when clicked. Shares all hb-switch inputs. | component | — |
| [hbIndicator] | Show the switch track on the right of the card. | boolean | true |