AccrueAdmin.Components.Toggle (accrue_admin v1.5.0)

Copy Markdown View Source

Accessible toggle switch (ARIA switch role) for mounted admin pages.

Uses role="switch" and aria-checked per the ARIA Authoring Practices Guide (APG). Keyboard users can activate via Space or Enter. An optional hidden <input type="hidden"> can emit the boolean form value when wired (see hidden_name attr).

The <button role="switch"> approach is preferred over a native checkbox because it provides cleaner visual separation between the toggle track/thumb and the label affordance.

Summary

Functions

toggle(assigns)

Attributes

  • id (:string) (required)
  • name (:string) (required)
  • label (:string) (required)
  • on (:boolean) - Defaults to false.
  • disabled (:boolean) - Defaults to false.
  • Global attributes are accepted. Supports all globals plus: ["phx-click", "phx-value-id", "form", "phx-hook"].