Radio Group

3 Radio Group variations from the W3C ARIA Authoring Practices Guide.

Radio Group (activedescendant)

The same pizza choices keep DOM focus on each group and expose the active radio through aria-activedescendant.

Corresponding W3C APG example

Example

Pizza crust

Delivery method

No options selected.

Keyboard interaction

Tab enters the group at its selected option. Arrow keys move and select with wrapping. Space selects the focused option. Tab leaves the group.

Events

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

  • axxy-radio-change — Dispatched when the selected radio option changes. (target: Checked [role="radio"], detail: { item: HTMLElement, value: string })

Events reference and examples

Example HTML

<axxy-scope>
  <h2 id="crust-label">Pizza crust</h2>
  <div role="radiogroup" tabindex="0" aria-labelledby="crust-label">
    <button>Regular crust</button>
    <button>Deep dish</button>
    <button>Thin crust</button>
  </div>
  <h2 id="delivery-label">Delivery method</h2>
  <div role="radiogroup" tabindex="0" aria-labelledby="delivery-label">
    <button>Pickup</button>
    <button>Home delivery</button>
    <button>Dine in</button>
  </div>
  <p role="status" data-radio-output>No options selected.</p>
  <button type="button">Continue</button>
</axxy-scope>

Radio Group (Rating)

Five individually named star options form a rating radio group. The selected rating is reported in text.

Corresponding W3C APG example

Example

No rating selected.

Keyboard interaction

Tab enters the group at its selected option. Arrow keys move and select with wrapping. Space selects the focused option. Tab leaves the group.

Events

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

  • axxy-radio-change — Dispatched when the selected radio option changes. (target: Checked [role="radio"], detail: { item: HTMLElement, value: string })

Events reference and examples

Example HTML

<axxy-scope>
  <div role="radiogroup" aria-label="Your rating">
    <button aria-label="1 star">
      <span aria-hidden="true">★</span>
    </button>
    <button aria-label="2 stars">
      <span aria-hidden="true">★★</span>
    </button>
    <button aria-label="3 stars">
      <span aria-hidden="true">★★★</span>
    </button>
    <button aria-label="4 stars">
      <span aria-hidden="true">★★★★</span>
    </button>
    <button aria-label="5 stars">
      <span aria-hidden="true">★★★★★</span>
    </button>
  </div>
  <p role="status" data-radio-output>No rating selected.</p>
</axxy-scope>

Radio Group (Roving tabindex)

Two independent radio groups use roving tabindex. Selecting a pizza crust does not change the selected delivery method.

Corresponding W3C APG example

Example

Pizza crust

Delivery method

No options selected.

Keyboard interaction

Tab enters the group at its selected option. Arrow keys move and select with wrapping. Space selects the focused option. Tab leaves the group.

Events

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

  • axxy-radio-change — Dispatched when the selected radio option changes. (target: Checked [role="radio"], detail: { item: HTMLElement, value: string })

Events reference and examples

Example HTML

<axxy-scope>
  <h2 id="crust-label">Pizza crust</h2>
  <div role="radiogroup"  aria-labelledby="crust-label">
    <button>Regular crust</button>
    <button>Deep dish</button>
    <button>Thin crust</button>
  </div>
  <h2 id="delivery-label">Delivery method</h2>
  <div role="radiogroup"  aria-labelledby="delivery-label">
    <button>Pickup</button>
    <button>Home delivery</button>
    <button>Dine in</button>
  </div>
  <p role="status" data-radio-output>No options selected.</p>
  <button type="button">Continue</button>
</axxy-scope>