This documentation is under construction. Pages can be missing or change at any time. Follow it on GitHub.

Skip to content

Radio Group

Provides shared state to a series of radio buttons.

Examples#

Labeling a radio group#

Label the group with aria-labelledby and a sibling label element. An enclosing <label> is the simplest labeling pattern for each radio.

Rendering as a native button#

By default, Radio renders a <span> element to support enclosing labels. Prefer rendering each radio as a native button with nativeButton when using sibling labels (for/id).

Form integration#

Use Field and Fieldset for group labeling and form integration.

API reference#

Import the components of the family:

use Phem\Ui\RadioGroup;
use Phem\Ui\Radio;
use function Phem\Ui\RadioIndicator;

RadioGroup#

A group of radio buttons: Base UI RadioGroup, on the phem-radio-group controller.

defaultValue is the value of the checked radio. A hidden input keeps the value for a form (name). Bind it to a state of the app with phem:bind. Label the group with aria-labelledby. With required, a group with no checked radio stops the submit of its form, and the focus goes to the radio of the tab stop.

PropTypeDefault
defaultValue?stringnull
name?stringnull
disabledboolfalse
readOnlyboolfalse
requiredboolfalse
value?Boundnull
children?Htmlnull
...attrsarray[]

Radio#

A radio of the group: Base UI Radio.Root. Put it in a <label> with its text.

PropTypeDefault
value (required)string—
disabledboolfalse
nativeButtonboolfalse
children?Htmlnull
...attrsarray[]

RadioIndicator#

The dot of a checked radio.

PropTypeDefault
...restmixed—

The source of the examples: examples/ui/RadioGroup.phem.

Phem
Esc
↑↓ to navigate↵ to openEsc to close