[ @sdxc/ui/mixins ]
pressToggle
Why JS.
import { pressToggle } from "@sdxc/ui/mixins";Usage
Flips a ToggleButton's aria-pressed attribute on every click and
dispatches PressToggleChangeEvent, keeping the attribute already
rendered onto the host as the single source of truth for pressed state.
Signature
pressToggle(): MixinDescriptor<HTMLButtonElement>Returns a mixin descriptor for a ToggleButton's mix prop.
Examples
<button aria-pressed="false" mix={pressToggle()}>Mute</button>Used with it
The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.
Event
PressToggleChangeEvent
Dispatched on a ToggleButton by pressToggle right after a click
flips its aria-pressed attribute, carrying the value so a consumer can
persist it or mirror it onto another element without reading it back.
new PressToggleChangeEvent(pressed: boolean)| Property | Type | Description |
|---|---|---|
pressed | readonly boolean | The host's aria-pressed value immediately after this click. |