A two-state action such as a persistent filter. A native button exposes
aria-pressed, while its visible label stays stable. Use a checkbox for agreement
or required acceptance and a switch for an immediate on/off setting.
<script type="module" src="/assets/components/toggle-button/qds-toggle-button.js"></script>
<qds-toggle-button label="Priority only" name="priority" value="high"></qds-toggle-button>
| Property / attribute | Type | Default | Meaning |
|---|---|---|---|
checked property |
boolean | false | Current state; programmatic assignments are silent. |
checked attribute / defaultChecked |
boolean | false | Reset state; updates current state until the first property/user change. |
label |
string | empty | Visible fallback label. Default slot content overrides it. |
aria-label |
string | empty | Explicit accessible name when needed. |
name, form |
string | empty | Native field name and optional associated form ID. |
value |
string | on | Submitted only while checked and enabled. |
disabled |
boolean | false | Blocks focus/activation and submission, including disabled fieldsets. |
loading |
boolean | false | Busy indicator and activation guard. |
readonly |
boolean | false | Keeps the current state, focusability and submission value. Explain this state in nearby visible content. |
variant |
primary / secondary / quiet / destructive | secondary | Resting appearance; checked appearance uses accent tokens. |
size |
sm / md / lg | md | Visual size, with a minimum 44px target. |
Slots: default stable label, icon, suffix. Parts: button, label, icon,
suffix, spinner. Icons should be decorative when the label already names the
action. Existing theme tokens cover both modes, reduced motion and forced colors.
Enter, Space and pointer activation emit a cancelable host click. Canceling it
keeps state unchanged. Successful user toggles emit input, then change, each
with { component, checked, value }. Both bubble across shadow boundaries.
Disabled, loading and readonly activations never toggle. Programmatic changes,
reset and state restoration do not emit user input/change events.
The current state is exposed as aria-pressed on the native button. Keep its
accessible label stable as the state changes. This is a toggle action with no
required/invalid agreement constraint. It contributes the checked string value
to native FormData and restores the default on native form reset. Toggle
activation never submits or resets the form, even if a type attribute is set.
Reconnect retains current state and reinstalls only one activation listener.
The generated Quangular wrapper implements a boolean ControlValueAccessor:
[formControl] and formControlName read/write checked, separately from the
string submission value. Angular reset, touched and disabled behavior use the
shared form adapter.
Northwind’s /#/investments/pipeline uses the generated wrapper in its filter
form. Priority only narrows fictional opportunities to readiness scores of 80
or above. Reset filters restores the full list. The grouped actions are reachable
through Investments > Pipeline; the screen states the threshold and displays the
matching count. This local filter state does not persist after leaving the screen.