Fragiola

API: components

Radio

A radio of a RadioGroup and its dot, with the hidden input the form submits, following the APG's radio group pattern, in each framework.

One choice of a RadioGroup (WAI-ARIA APG radio group pattern): a button with the radio role, its dot, and a hidden radio input that the form submits. A Radio.Root must be inside a RadioGroup, which holds the value, the tab stop and the arrow keys.

Contact settings
Gallery

Behaviour

  • Check: a click on the Root or on its <label> checks it and focuses it, as does Space on it; Enter does nothing. A checked radio stays checked: another radio of the group clears it.
  • Disabled: disabled, or the group's, ignores the pointer and the keys, and the arrows skip it.
  • Forms: a visually hidden radio input right after the Root carries the group's name, the radio's value and its checked state. It is never in the accessibility tree nor the tab order.
  • Name: a <label> around the Root, <label for> (the Root is a button, which is labelable), or aria-label.

Anatomy

partelementdata-primitives-partrole
Rootbuttonradio-roota radio of its group
Indicatorspanradio-indicatorthe dot; rendered only while checked
(hidden input)input type="radio"radio-inputwhat the form submits

Usage

import { Radio } from "@fragiola/primitives-react/radio";

<label>
    <Radio.Root value="pro">
        <Radio.Indicator />
    </Radio.Root>
    Pro
</label>;

Each sits inside a RadioGroup.

Props

Every part also takes what the primitive contract gives: render (Vue: as and the render slot), a class and a style, a ref, and any attribute, which it forwards.

Root

proptypedefaultdescription
valuestringrequiredits value in the group
disabledbooleanfalsethis radio only
idstringthe button's id, for a <label for>

Indicator

proptypedefaultdescription
keepMountedbooleanfalserendered in every state (Angular: *radioIndicator="true")

State and part attributes

partattributes
Rootrole="radio", type="button", aria-checked ("true" or "false"), tabindex (0 on the group's tab stop, -1 on the others), disabled and data-disabled when disabled (itself or the group), data-checked / data-unchecked (exactly one), data-required
Indicatoraria-hidden="true", data-checked / data-unchecked, data-disabled
hidden inputtype="radio", name, value, checked, required, disabled, aria-hidden="true", tabindex="-1", visually hidden

Keyboard

keyaction
Spacechecks the focused radio
Enternothing
Arrowsthe group's: the next or previous enabled radio, focused and checked

Exports

entryexports
@fragiola/primitives-react/radioRadio, RadioIndicatorProps, RadioRootProps, RadioState, RenderProp
@fragiola/primitives-vue/radioRadio, RadioIndicatorProps, RadioRootProps, RadioState, RenderSlotProps
@fragiola/primitives-angular/radioRadioIndicator, RadioRoot, RadioState