SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

pressToggle

Why JS.

tsx
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

typescript
pressToggle(): MixinDescriptor<HTMLButtonElement>

Returns a mixin descriptor for a ToggleButton's mix prop.

Examples

tsx
<button aria-pressed="false" mix={pressToggle()}>Mute</button>

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.

typescript
new PressToggleChangeEvent(pressed: boolean)
PropertyTypeDefaultRequiredDescription
pressedreadonly boolean—YesThe host's aria-pressed value immediately after this click.
@sdxc/ui

Can’t find it? Contact us