Button

2 Button variations from the W3C ARIA Authoring Practices Guide.

Button

Custom action and toggle buttons enhanced with keyboard activation and pressed state.

Corresponding W3C APG example

Example

Button
Toggle

Keyboard interaction

Tab reaches each control. Enter or Space activates it. Toggle labels stay unchanged.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-toggle-change — Dispatched when a toggle button changes its pressed state. (target: Toggle <button> / [aria-pressed], detail: { pressed: boolean })
  • click — Standard activation event. (target: <button> / [role="button"], detail: Native MouseEvent, cancelable)

Events reference and examples

Example HTML

<axxy-scope>
  <div role="button" id="demo-action">Button</div>
  <a role="button" aria-pressed="false" id="demo-toggle">Toggle</a>
  <p role="status" id="demo-status"></p>
</axxy-scope>

Button (IDL)

Custom action and toggle buttons using ARIA IDL reflection properties.

Corresponding W3C APG example

Example

Button
Toggle

Keyboard interaction

Tab reaches each control. Enter or Space activates it. Toggle labels stay unchanged.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-toggle-change — Dispatched when a toggle button changes its pressed state. (target: Toggle <button> / [aria-pressed], detail: { pressed: boolean })
  • click — Standard activation event. (target: <button> / [role="button"], detail: Native MouseEvent, cancelable)

Events reference and examples

Example HTML

<axxy-scope>
  <div role="button" id="demo-action">Button</div>
  <a role="button" aria-pressed="false" id="demo-toggle">Toggle</a>
  <p role="status" id="demo-status"></p>
</axxy-scope>