Skip to content
Bitsy UI 0.x
Theme
Menu: Radio Group
  1. Docs
  2. Bits

Radio Group

Radio Group lets a person pick exactly one option from a small visible set. The group is the Bit: a native fieldset and legend, radios that share one name, optional option and group descriptions, and one group error. No JavaScript.

Public web API

One root hook on the fieldset, one hook per option, and two message hooks. Selection, keyboard movement, and validation stay native.

<fieldset data-bitsy-radio-group aria-describedby="plan-help">
  <legend>Plan</legend>
  <p id="plan-help" data-bitsy-radio-group-description>
    You can change plans at any time.
  </p>
  <div data-bitsy-radio-group-option>
    <input id="plan-starter" type="radio" name="plan" value="starter" checked
      aria-describedby="plan-starter-help" />
    <label for="plan-starter">Starter</label>
    <p id="plan-starter-help" data-bitsy-radio-group-description>
      One project and community support.
    </p>
  </div>
  <div data-bitsy-radio-group-option>
    <input id="plan-team" type="radio" name="plan" value="team" />
    <label for="plan-team">Team</label>
  </div>
  <p id="plan-error" data-bitsy-radio-group-error>Choose a plan.</p>
</fieldset>

Add data-bitsy-orientation="horizontal" for a wrapping row and data-bitsy-size="sm" for the compact size. Put aria-invalid="true" and the error id on the fieldset, never on one radio.

Variants and states

Use the arrow keys inside a group and Tab to leave it. Click a label to choose its option.

Vertical with descriptions
Plan

You can change plans at any time.

One project and community support.

Unlimited projects and shared billing.

SSO, audit logs, and a support contract.

Small size
Table density
Horizontal
Email notifications
Availability
Delivery speed

Not available for this address.

Data region

The region is fixed after the workspace is created.

Required and invalid
Team size (required)

Choose a team size.

Foundation versus Bit

Raw radios stay native in the foundation, and a raw fieldset is a bordered panel. data-bitsy-radio-group removes the panel, draws the radio, and adds option layout, descriptions, orientation, and the group error. A boxed group is the Fieldset Bit's job, and large radio cards are a later Pattern built on this Bit.

Bitsy UI is MIT licensed. Source on GitHub.