Skip to content

RadioGroup

RadioGroup lets users select one option from a set of mutually exclusive choices. For independent toggles, use Checkbox.

Code
<RadioGroup defaultValue="comfortable">
<div className="tw:flex tw:items-center tw:gap-2">
<RadioGroupItem value="default" id="default" />
<Label htmlFor="default">Default</Label>
</div>
<div className="tw:flex tw:items-center tw:gap-2">
<RadioGroupItem value="comfortable" id="comfortable" />
<Label htmlFor="comfortable">Comfortable</Label>
</div>
<div className="tw:flex tw:items-center tw:gap-2">
<RadioGroupItem value="compact" id="compact" />
<Label htmlFor="compact">Compact</Label>
</div>
</RadioGroup>
NameType/Description
classNamestring | ((state: RadioGroupState) => string | undefined) | undefined
CSS class applied to the element, or a function that returns a class based on the component's state.
defaultValueany
The uncontrolled value of the radio button that should be initially selected. To render a controlled radio group, use the `value` prop instead.
disabled = falseboolean | undefined
Whether the component should ignore user interaction.
formstring | undefined
Identifies the form that owns the radio inputs. Useful when the radio group is rendered outside the form.
inputRefRef<HTMLInputElement> | undefined
A ref to access the hidden input element.
namestring | undefined
Identifies the field when a form is submitted.
onValueChange((value: any, eventDetails: { reason: "none"; event: Event; cancel: () => void; allowPropagation: () => void; isCanceled: boolean; isPropagationAllowed: boolean; trigger: Element | undefined; }) => void) | undefined
Callback fired when the value changes.
readOnly = falseboolean | undefined
Whether the user should be unable to select a different radio button in the group.
ref((instance: HTMLDivElement | null) => void) | RefObject<HTMLDivElement> | null | undefined
renderReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioGroupState> | undefined
Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
required = falseboolean | undefined
Whether the user must choose a value before submitting a form.
styleCSSProperties | ((state: RadioGroupState) => CSSProperties | undefined) | undefined
Style applied to the element, or a function that returns a style object based on the component's state.
valueany
The controlled value of the radio item that should be currently selected. To render an uncontrolled radio group, use the `defaultValue` prop instead.
NameType/Description
classNamestring | ((state: RadioRootState) => string | undefined) | undefined
CSS class applied to the element, or a function that returns a class based on the component's state.
disabledboolean | undefined
Whether the component should ignore user interaction.
inputRefRef<HTMLInputElement> | undefined
A ref to access the hidden input element.
nativeButton = falseboolean | undefined
Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button.
readOnlyboolean | undefined
Whether the user should be unable to select the radio button.
ref((instance: HTMLSpanElement | null) => void) | RefObject<HTMLSpanElement> | null | undefined
renderReactElement<any, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, RadioRootState> | undefined
Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.
requiredboolean | undefined
Whether the user must choose a value before submitting a form.
styleCSSProperties | ((state: RadioRootState) => CSSProperties | undefined) | undefined
Style applied to the element, or a function that returns a style object based on the component's state.
valueany
The unique identifying value of the radio in a group.