ToggleGroup <pm-toggle-group>
Toggle button group (text formatting, filters, view options).
Variants
Set with the variant attribute.
variant="outline"variant="ghost"variant="soft"Sizes
Set with the size attribute; controls keep touch-sized targets on phones.
size="sm"size="md"size="lg"Tones
Set tone on the element, or data-tone on any ancestor to tone a whole area.
tone="accent"tone="secondary"tone="neutral"tone="success"tone="warning"tone="danger"tone="info"States
Each state is one attribute.
DisabledRead-onlyRequiredErrorWith a hintOverview
Single selection by default (click again to clear); multiple allows several. Value is the pressed toggles' values, comma-separated with multiple (values is the same as a list). Arrow keys move between toggles (roving tabindex), Space/Enter toggles. Form-associated.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
hint | string | — | Help text under the field, linked to it for screen readers. |
error | string | — | Custom error message. Setting it marks the field invalid. |
value | string | — | Pressed value(s); comma-separated with multiple. |
name | string | — | Form field name: the value is submitted under it (one entry per pressed toggle with multiple). |
label | string | — | Accessible name of the group (not shown on screen). |
multiple | boolean | false | Allow several toggles to be pressed at once. |
required | boolean | false | At least one toggle must be pressed: the form cannot be submitted while none is. In single mode the pressed toggle also cannot be clicked off (another one can still be chosen). |
size | 'sm' | 'md' | 'lg' | — | Toggle size. |
variant | 'outline' | 'ghost' | 'soft' | — | Look of the toggles. |
orientation | 'horizontal' | 'vertical' | — | Lay the toggles out in a row (default) or a column. |
disabled | boolean | false | Not interactive and not submitted. |
readonly | boolean | false | Focusable and submitted, but the user cannot change the value. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-change | onPmChange | Pressed toggles changed. detail.value is detail.values joined with commas. |
Slots
| Slot | Description |
|---|---|
(default) | pm-toggle elements. |
Methods
checkValidity(), reportValidity(), validate()
<pm-toggle>
One toggle button (aria-pressed). Use inside pm-toggle-group, or standalone as an on/off button.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
value | string | — | Current value. |
label | string | — | Accessible name for icon-only toggles. |
pressed | boolean | false | Whether the toggle is on. |
disabled | boolean | false | Not interactive (and not submitted, for form controls). |
size | 'sm' | 'md' | 'lg' | — | Size: sm, md or lg (md when not set). |
variant | 'outline' | 'ghost' | 'soft' | — | Visual style. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-change | onPmChange | Standalone toggle changed. |
Slots
| Slot | Description |
|---|---|
(default) | Label (text and/or icon). Icon-only toggles need label. |