Skip to main content
Version: 1.x

fast-radio-group

As defined by the W3C:

A radio group is a set of checkable buttons, known as radio buttons, where no more than one of the buttons can be checked at a time. Some implementations may initialize the set with all buttons in the unchecked state in order to force the user to check one of the buttons before moving past a certain point in the workflow.

While any DOM content is permissible as a child of the radiogroup, only fast-radio's and slotted content with a role of radio will receive keyboard support.

Setup

import {
provideFASTDesignSystem,
fastRadio,
fastRadioGroup
} from "@microsoft/fast-components";

provideFASTDesignSystem()
.register(
fastRadio(),
fastRadioGroup()
);

Usage

Live Editor
<fast-radio-group value="mango" name="favorite-fruit">
    <fast-radio value="apple">Apple</fast-radio>
    <fast-radio value="mango">Mango</fast-radio>
    <fast-radio value="orange">Orange</fast-radio>
</fast-radio-group>
Result
Loading...

Create your own design

import { RadioGroup, radioGroupTemplate as template } from "@microsoft/fast-foundation";
import { radioGroupStyles as styles } from "./my-radio-group.styles";

export const myRadioGroup = RadioGroup.compose({
baseName: "radio-group",
template,
styles,
});

API

class: RadioGroup

Superclass

NameModulePackage
FoundationElement/src/foundation-element/foundation-element.js

Fields

NamePrivacyTypeDefaultDescriptionInherited From
readOnlypublicbooleanWhen true, the child radios will be immutable by user interaction. See readonly HTML attribute for more information.
disabledpublicbooleanDisables the radio group and child radios.
namepublicstringThe name of the radio group. Setting this value will set the name value for all child radio elements.
valuepublicstringThe value of the checked radio
orientationpublicOrientation or "horizontal" or "vertical"The orientation of the group
childItemspublicHTMLElement[]
$presentationpublicComponentPresentation or nullA property which resolves the ComponentPresentation instance for the current component.FoundationElement
templatepublicElementViewTemplate or void or nullSets the template of the element instance. When undefined, the element will attempt to resolve the template from the associated presentation or custom element definition.FoundationElement
stylespublicElementStyles or void or nullSets the default styles for the element instance. When undefined, the element will attempt to resolve default styles from the associated presentation or custom element definition.FoundationElement

Methods

NamePrivacyDescriptionParametersReturnInherited From
nameChangedprotectedvoid
valueChangedprotectedvoid
templateChangedprotectedvoidFoundationElement
stylesChangedprotectedvoidFoundationElement

Events

NameTypeDescriptionInherited From
changeFires a custom 'change' event when the value changes

Attributes

NameFieldInherited From
readonlyreadOnly
disableddisabled
namename
valuevalue
orientationorientation

CSS Parts

NameDescription
positioning-regionThe positioning region for laying out the radios

Slots

NameDescription
labelThe slot for the label
The default slot for radio buttons

Additional resources