Comparison: Native vs. Focusgroup
Side-by-side comparison showing that a focusgroup
radio group can behave comparably to native <input type="radio">.
Try it: Use ↓ ↑ to
navigate in both groups. Selection-follows-focus is on
by default (matching native radio behavior). Toggle the switch to
disable it and see how arrow keys move focus without selecting.
focusgroup="radiogroup block wrap nomemory"
Native Radio Buttons
Focusgroup Radio Group
Red
Green
Blue
Purple
- Both groups use arrow keys to navigate between options
- Both are single tab stops. Tab enters, arrows navigate, and Tab exits
- The
focusgroupversion can be styled with CSS without browser-default appearance -
Selection follows focus (on, default): Moving focus
also selects the option, matching native radio behavior and the
APG Radio Group pattern
requirement.
Selection follows focus (off): Arrow keys
only move focus;
press Enter or Space to select.
This mode is shown for comparison only. It is non-conformant for
role="radio". radiogrouphas no default axis modifier. Unlikemenu(which defaults toblock wrap) ortablist(which defaults toinline wrap), you must explicitly addblockorinline.blockhere sets the navigation axis to Up/Down.wrapmatches native radio behavior, looping from last to first and first to last.- The
radiogrouptoken mapsrole="radiogroup"on the container and infersrole="radio"on each generic child (including<span>). <span>is not natively focusable. Give every itemtabindex="0"so the browser can focus it.focusgroupcollapses those into one tab stop.- JavaScript moves
focusgroupstartto the selected item on each selection change. Combined withnomemory, Tab re-entry lands on the checked option.
View source
<div focusgroup="radiogroup block wrap nomemory"
aria-label="Favorite color" class="radio-group radio-group-column">
<span aria-checked="true" tabindex="0"
class="radio-option checked" focusgroupstart>Red</span>
<span aria-checked="false" tabindex="0"
class="radio-option">Green</span>
<span aria-checked="false" tabindex="0"
class="radio-option">Blue</span>
<span aria-checked="false" tabindex="0"
class="radio-option">Purple</span>
</div>
Key Point: Navigation vs. Selection
With native <input type="radio">, moving
focus with arrows also selects the option (selection-follows-focus).
The APG Radio Group pattern
normatively requires this behavior for role="radio".
With focusgroup, selection-follows-focus is implemented
in JavaScript and is on by default in this demo.
The toggle above can disable it to show the non-conformant
"deferred selection" mode (where Enter/Space
confirms selection). It is provided for comparison only.