Back to Fluentui

Radio

packages/web-components/src/radio/README.md

4.40.2-hotfix24.7 KB
Original Source

Radio

Radio buttons allow users to select a single option from two or more choices. Radio buttons are typically rendered as small circles, which are filled or highlighted when selected.

Design Spec

Link to Radio Design Spec in Figma

Engineering Spec

Fluent WC3 Radio is a form associated component that extends from the FAST Radio FAST Radio and is intended to be as close to the Fluent UI React 9 Menu implementation as possible. However, due to the nature of web components there will not be 100% parity between the two.

Use Case

Used anywhere an author might otherwise use an input[type="radio"]. Used to facilitate choice where only one choice is acceptable.

Class: Radio

Component Name

fluent-radio

Variables

Fields

NamePrivacyTypeDefaultDescription
namepublicstringThe name of the radio. See name attribute for more info. When the radio component is rendered inside a radio-group, the radio-group overwrites the name in all its radio components.
disabledpublicbooleanSets disabled state for radio
checkedpublicbooleanfalseWhen true, radio button will be checked

Methods

Attributes

NameField
namename
disableddisabled
checkedchecked

Slots

NameDescription
checked-indicatorThe checked indicator
Default slotted content for label text
<hr />

Suggested Template

radioTemplate from FastFoundation

<hr />

Accessibility

W3 Radio Spec

WAI-ARIA Roles, States, and Properties

AttributesvalueDescription
roleradio
aria-checkedthe checked state of the component
aria-requiredthe required state of the component
aria-disabledthe disabled state of the component
tabindex0
<hr />

Preparation

Fluent Web Component v3 v.s Fluent React 9

Deltas

In contrast to the FUIRv9 implimentation of the Radio component the WC3 Radio must be rendered inside the WC3 RadioGroup to inherit all appropriate styles.

html
<fluent-radio-group>
  <fluent-radio></fluent-radio>
</fluent-radio-group>

Component and Slot Mapping

Fluent UI React 9Fluent Web Components 3
<Radio><fluent-radio>

Property Mapping

Fluent UI React 9Fluent Web Components 3Description of difference
prop labeldefault slotted contentReact implementation requires user to pass a string through the label prop on the Radio component

The web component implementation requires users to pass the label text through the default slotted content