Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Forms Form-associated

ToggleGroup <pm-toggle-group>

Toggle button group (text formatting, filters, view options).

Full screen

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/icon'; import '@prismora/elements/toggle-group'; import { registerIcons } from '@prismora/elements/icon'; import { alignCenter, alignLeft, alignRight, bold, italic, underline } from '@prismora/icons'; registerIcons([alignCenter, alignLeft, alignRight, bold, italic, underline]); </script> <pm-toggle-group label="Text style" multiple value="bold"> <pm-toggle value="bold" label="Bold"> <pm-icon name="bold"></pm-icon> </pm-toggle> <pm-toggle value="italic" label="Italic"> <pm-icon name="italic"></pm-icon> </pm-toggle> <pm-toggle value="underline" label="Underline"> <pm-icon name="underline"></pm-icon> </pm-toggle> </pm-toggle-group> <pm-toggle-group label="Alignment" value="left" required> <pm-toggle value="left" label="Align left"> <pm-icon name="align-left"></pm-icon> </pm-toggle> <pm-toggle value="center" label="Align centre"> <pm-icon name="align-center"></pm-icon> </pm-toggle> <pm-toggle value="right" label="Align right"> <pm-icon name="align-right"></pm-icon> </pm-toggle> </pm-toggle-group>

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.

Disabled
Read-only
Required
Error
With a hint

Overview

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

AttributeTypeDefaultDescription
hintstring—Help text under the field, linked to it for screen readers.
errorstring—Custom error message. Setting it marks the field invalid.
valuestring—Pressed value(s); comma-separated with multiple.
namestring—Form field name: the value is submitted under it (one entry per pressed toggle with multiple).
labelstring—Accessible name of the group (not shown on screen).
multiplebooleanfalseAllow several toggles to be pressed at once.
requiredbooleanfalseAt 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.
disabledbooleanfalseNot interactive and not submitted.
readonlybooleanfalseFocusable 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

EventReact / Svelte propDescription
pm-changeonPmChangePressed toggles changed. detail.value is detail.values joined with commas.

Slots

SlotDescription
(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

AttributeTypeDefaultDescription
valuestring—Current value.
labelstring—Accessible name for icon-only toggles.
pressedbooleanfalseWhether the toggle is on.
disabledbooleanfalseNot 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

EventReact / Svelte propDescription
pm-changeonPmChangeStandalone toggle changed.

Slots

SlotDescription
(default)Label (text and/or icon). Icon-only toggles need label.

Used in templates

Feedback survey