API reference
<tng-switch> is built on the tngSwitch primitive. Most component consumers will stay at the wrapper layer, but it helps to understand which primitive inputs are flowing through.
Underlying primitive: tngSwitch
The wrapper forwards checked, disabled, required, and ariaLabel to the internal switch button that owns the ARIA role and state attributes.
Primitive attachment
<button
tngSwitch
[checked]="releaseReady()"
ariaLabel="Release ready"
(click)="releaseReady.update(value => !value)"
>
<span class="switch-thumb" aria-hidden="true"></span>
</button>
| Forwarded primitive surface | Notes |
|---|---|
checked | Controls the visual state and aria-checked value. |
disabled | Blocks interaction and reflects disabled styling hooks on the button. |
required | Reflects aria-required for assistive technology. |
ariaLabel | Accessible name when the projected label needs different spoken copy. |
If you need custom thumb markup or direct styling against the primitive button state, move to Headless > Form > Switch or the ownable surface.
tng-switch (styled component)
The wrapper renders the default track and thumb, syncs a hidden checkbox for native form submission, and exposes Angular-friendly checkedChange events for controlled usage.
Component attachment
<tng-switch
[checked]="releaseReady()"
(checkedChange)="releaseReady.set($event)"
>
Release ready
</tng-switch>
| Input | Type | Default | Details |
|---|---|---|---|
checked | boolean | false | Committed on/off state when the component is used in controlled mode. |
disabled | boolean | false | Disables the visible switch button and the hidden checkbox. |
required | boolean | false | Marks the hidden checkbox as required and forwards ARIA required state. |
name | string | null | null | Native form field name for HTML form submission. |
value | string | 'on' | Submitted value for the hidden checkbox when checked. |
ariaLabel | string | null | null | Accessible name override for the internal switch button. |
| Surface | Type | Notes |
|---|---|---|
checkedChange | EventEmitter<boolean> | Emits the next checked state after click or arrow-key interaction. |
| Projected label content | <ng-content> | Visible switch label shown next to the control. |
| Icon slots | [onIcon], [offIcon] | Optional projected icons rendered inside the thumb. |
| Keyboard behavior | ArrowLeft, ArrowRight, click | ArrowLeft forces off, ArrowRight forces on, and click handles the regular toggle. |
Hidden input in native forms
<form>
<tng-switch name="autoPublish" value="enabled" [checked]="true">
Auto publish after review
</tng-switch>
</form>
tng-switch is not a ControlValueAccessor. Bind it with checked and checkedChange, or drop to headless/ownable if you need a different forms integration strategy.