Select one option from a set of mutually exclusive choices. Perfect for single-choice questions and settings.
import { Radio } from '@fluxui-dev/react';<Radio.Group label="Select your payment method" defaultValue="cc"> <Radio value="cc" label="Credit Card" /> <Radio value="paypal" label="Paypal" /> <Radio value="ach" label="Bank transfer" /></Radio.Group>
Align descriptions for each radio directly below its label.
<Radio.Group label="Role" name="role" defaultValue="administrator"> <Radio value="administrator" label="Administrator" description="Administrator users can perform any action." /> <Radio value="editor" label="Editor" description="Editor users have the ability to read, create, and update." /> <Radio value="viewer" label="Viewer" description="Viewer users only have the ability to read. Create, and update are restricted." /></Radio.Group>
A more compact alternative to standard radio buttons.
<Radio.Group label="Role" variant="segmented" defaultValue="administrator"> <Radio value="administrator" label="Admin" /> <Radio value="editor" label="Editor" /> <Radio value="viewer" label="Viewer" /></Radio.Group>
You can also use the size="sm" prop to make the radios smaller.
<Radio.Group label="Role" variant="segmented" size="sm" defaultValue="administrator"> <Radio value="administrator" label="Admin" /> <Radio value="editor" label="Editor" /> <Radio value="viewer" label="Viewer" /></Radio.Group>
Combine segmented radio buttons with icon prefixes.
import { EyeIcon, PencilSquareIcon, WrenchIcon } from '@fluxui-dev/react/icons';<Radio.Group variant="segmented" defaultValue="administrator"> <Radio value="administrator" label="Admin" icon={WrenchIcon} /> <Radio value="editor" label="Editor" icon={PencilSquareIcon} /> <Radio value="viewer" label="Viewer" icon={EyeIcon} /></Radio.Group>
A bordered alternative to standard radio buttons.
<Radio.Group label="Shipping" variant="cards" defaultValue="standard" className="max-sm:flex-col"> <Radio value="standard" label="Standard" description="4-10 business days" /> <Radio value="fast" label="Fast" description="2-5 business days" /> <Radio value="next-day" label="Next day" description="1 business day" /></Radio.Group>
You can swap between vertical and horizontal card layouts by conditionally applying flex-col based on the viewport.
<Radio.Group ... className="max-sm:flex-col"> {/* ... */}</Radio.Group>
You can arrange a set of radio cards vertically by simply adding the flex-col class to the group container.
<Radio.Group label="Shipping" variant="cards" className="flex-col"> <Radio value="standard" label="Standard" description="4-10 business days" /> <Radio value="fast" label="Fast" description="2-5 business days" /> <Radio value="next-day" label="Next day" description="1 business day" /></Radio.Group>
Pass an icon component to each card's icon prop to show it before the label.
import { ClockIcon, CubeIcon, TruckIcon } from '@fluxui-dev/react/icons';<Radio.Group label="Shipping" variant="cards" className="max-sm:flex-col"> <Radio value="standard" icon={TruckIcon} label="Standard" description="4-10 business days" /> <Radio value="fast" icon={CubeIcon} label="Fast" description="2-5 business days" /> <Radio value="next-day" icon={ClockIcon} label="Next day" description="1 business day" /></Radio.Group>
For a cleaner look, you can remove the radio indicator using indicator={false}.
<Radio.Group label="Shipping" variant="cards" indicator={false} className="max-sm:flex-col"> <Radio value="standard" icon={TruckIcon} label="Standard" description="4-10 business days" /> <Radio value="fast" icon={CubeIcon} label="Fast" description="2-5 business days" /> <Radio value="next-day" icon={ClockIcon} label="Next day" description="1 business day" /></Radio.Group>
You can compose your own custom cards through the Radio component's children.
import { Heading, Radio, Text } from '@fluxui-dev/react';<Radio.Group label="Shipping" variant="cards" defaultValue="standard" className="max-sm:flex-col"> <Radio value="standard"> <Radio.Indicator /> <div className="flex-1"> <Heading className="leading-4">Standard</Heading> <Text size="sm" className="mt-2">4-10 business days</Text> </div> </Radio> <Radio value="fast"> <Radio.Indicator /> <div className="flex-1"> <Heading className="leading-4">Fast</Heading> <Text size="sm" className="mt-2">2-5 business days</Text> </div> </Radio> <Radio value="next-day"> <Radio.Indicator /> <div className="flex-1"> <Heading className="leading-4">Next day</Heading> <Text size="sm" className="mt-2">1 business day</Text> </div> </Radio></Radio.Group>
Compact, rounded radio buttons that look like tags or badges. Perfect for filters, categories, and any time you want lightweight selectable options.
<Radio.Group label="Priority" variant="pills" defaultValue="medium"> <Radio value="low" label="Low" /> <Radio value="medium" label="Medium" /> <Radio value="high" label="High" /> <Radio value="critical" label="Critical" /></Radio.Group>
Button-style radio options that look like a toolbar. Perfect for action selections and grouped controls where you want a more prominent visual style.
import { BugAntIcon, LightBulbIcon, QuestionMarkCircleIcon } from '@fluxui-dev/react/icons';<Radio.Group variant="buttons" className="w-full *:flex-1" label="Feedback type" defaultValue="bug"> <Radio value="bug" icon={BugAntIcon}>Bug report</Radio> <Radio value="suggestion" icon={LightBulbIcon}>Suggestion</Radio> <Radio value="question" icon={QuestionMarkCircleIcon}>Question</Radio></Radio.Group>
|
Prop
|
Description
|
|---|---|
| label |
Label text displayed above the radio group. When provided, wraps the radio group in a Field component with an adjacent Field.Label component. See the field component.
|
| description |
Help text displayed below the radio group. When provided alongside label, appears between the label and radio group within the Field wrapper. See the field component.
|
| error |
Error message displayed below the radio group, marking it invalid and defaulting to the validation error for the group's name.
|
| value |
Controlled selected value, paired with onValueChange.
|
| defaultValue |
Initially selected value when uncontrolled.
|
| onValueChange |
Callback fired when the selection changes, receiving the new value.
|
| name |
Form field name submitted with the selected radio value.
|
| variant |
Visual style of the group. Options: default, segmented, cards, pills, buttons. In development, a prop the variant ignores logs a console warning.
|
| size |
Size of the radios in a segmented or buttons group. Options: base (default), sm, xs (buttons only).
|
| indicator |
Controls card indicator placement: true or end after the text (default), start before it, or false to hide it.
|
| disabled |
Prevents user interaction with all radios in the group.
|
| invalid |
Sets aria-invalid and data-invalid on the radio group.
|
| className |
CSS classes applied to the group element. With label set, they stay on the group, below the label; to space the whole field, write the Field yourself and pass it className.
|
|
Slot
|
Description
|
|---|---|
| children |
The radio buttons to be grouped together.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-radio-group |
Applied to the root element for styling and identification.
|
Works only inside a Radio.Group, whose value decides which radio is selected.
|
Prop
|
Description
|
|---|---|
| label |
Label text displayed next to the radio button, or the text of a segment, card, pill, or button.
|
| description |
Help text displayed below the label, or the text below a card's heading.
|
| value |
Value associated with the radio button when used in a group.
|
| disabled |
Prevents user interaction with the radio button.
|
| icon |
Icon displayed before the label of a segment, card, or button: a component or an element.
|
| iconTrailing |
Icon displayed after the label of a segmented radio: a component or an element.
|
| indicator |
Where a card shows its indicator. Defaults to the group's indicator.
|
| accent |
Applies the accent color to a checked card, pill, or button when true (default), or zinc when false.
|
|
Slot
|
Description
|
|---|---|
| children |
Custom content for a card, segment, pill, or button, used in place of label.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-radio |
Applied to the root element for styling and identification.
|
| data-checked |
Applied when the radio button is selected.
|