Radio groups
Help people choose exactly one option from a related set.
Live preview
HTML
<fieldset style="border:0;padding:0;margin:0">
<legend class="xsh-label" style="margin-bottom:14px">Billing interval</legend>
<div class="xsh-stack">
<label class="xsh-choice">
<input type="radio" name="xsh-demo-billing" checked value="monthly">
<span>Monthly billing</span>
</label>
<label class="xsh-choice">
<input type="radio" name="xsh-demo-billing" value="yearly">
<span>Annual billing — save 20%</span>
</label>
</div>
</fieldset>Installation & markup
Include the local stylesheet and script once on the page, then place the component inside a data-xsh-ui root. The example above works without a build system.
<link rel="stylesheet" href="/dist/xshna-ui.css">
<div data-xsh-ui>
<!-- Add the HTML example above -->
</div>
<script defer src="/dist/xshna-ui.js"></script>Component API
Public classes, attributes and hooks used by this example. Keep the xsh- prefix intact.
| Identifier | Contract |
|---|---|
xsh-choice | Used by the example markup and component styles or behavior. |
fieldset | Used by the example markup and component styles or behavior. |
legend | Used by the example markup and component styles or behavior. |
input[type=radio] | Used by the example markup and component styles or behavior. |
Accessibility & keyboard
Native radio groups use Arrow keys to change selections once focused. A fieldset and legend provide the group label.
Implementation note. Keep a meaningful default where possible; avoid presenting contradictory choices.
Interaction contract
Behavioral components use the shared delegated runtime; visual-only primitives rely on semantic HTML and CSS. Runtime controls emit bubbling xsh:* CustomEvents; bind application handlers to those events when server persistence, API data or navigation is required.