Toggle

Switch a command between pressed and unpressed.

Live example

A reviewed public example, isolated from this page.

Open example
import { Toggle } from "heidi-ui";
import "heidi-ui/styles.css";

Copy this one primitive from its hosted source recipe or install the whole package from the Heidi UI overview.

Anatomy

  • root<button>

    Toggle button; aria-pressed conveys on/off. Space/Enter activate through the native button. Native handlers run once before the pressed-state transition and may cancel it with preventDefault.

    Uses native semantics

Root properties

  • defaultPressed
  • disabled
  • onPressedChange
  • pressed