Skip to main content

Radio Group

View as Markdown

An easily stylable radio button component.

Choose an option:
<primitives:radioGroup.root>
    <primitives:radioGroup.item>
        <primitives:radioGroup.itemControl />
        <primitives:radioGroup.itemText />
        <primitives:radioGroup.itemHiddenInput />
    </primitives:radioGroup.item>
    <primitives:radioGroup.indicator />
</primitives:radioGroup.root>
typo3 ui:add radio-group

Read more about installing Components and Primitives.

Disable specific radio options.

Select plan:

Disable the entire radio group.

Disabled group:

Start with no option selected by default.

Select your gender:

The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.

Provides shared radio group state and semantics. Renders a <div> element.

NameDescriptionRequiredDefault
defaultValuestring
The initial value of the checked radio when rendered. Use when you don't need to control the value of the radio group. Inherited from a surrounding field when available.
No
-
namestring
The name of the input fields in the radio. Useful for form submission. Inherited from a surrounding field when available.
No
-
formstring
The associate form of the underlying input.
No
-
disabledboolean
If `true`, the radio group will be disabled. Inherited from a surrounding field when available.
No
-
readOnlyboolean
Whether the radio group is read-only. Inherited from a surrounding field when available.
No
-
requiredboolean
If `true`, the radio group is marked as required. Inherited from a surrounding field when available.
No
-
orientationEnum\Orientation
Orientation of the radio group.
No
Vertical
invalidboolean
If `true`, the radio group is marked as invalid. Inherited from a surrounding field when available.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-radio-group-root<uid>
data-orientationThe orientation of the radio-group
data-disabledPresent when disabled
data-invalidPresent when invalid
data-requiredPresent when required

Labels the radio group. Renders a <span> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-radio-group-label<uid>
data-orientationThe orientation of the label
data-disabledPresent when disabled
data-invalidPresent when invalid
data-requiredPresent when required

Wraps a single radio item and makes it clickable. Renders a <label> element.

NameDescriptionRequiredDefault
valuestring
The value of the radio item.
Yes
-
disabledboolean
Whether the radio item is disabled.
No
-
invalidboolean
Whether the radio item is invalid.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-radio-group-item<uid>
data-focusPresent when focused
data-focus-visiblePresent when focused with keyboard
data-disabledPresent when disabled
data-readonlyPresent when read-only
data-state"checked" | "unchecked"
data-hoverPresent when hovered
data-invalidPresent when invalid
data-orientationThe orientation of the item
data-ssrPresent when not rendered in the browser. Useful for ssr styling

Provides the native radio input for form submission. Renders an <input> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Displays the visual radio control. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-radio-group-item-control<uid>
data-activePresent when active or pressed
data-focusPresent when focused
data-focus-visiblePresent when focused with keyboard
data-disabledPresent when disabled
data-readonlyPresent when read-only
data-state"checked" | "unchecked"
data-hoverPresent when hovered
data-invalidPresent when invalid
data-orientationThe orientation of the item
data-ssrPresent when not rendered in the browser. Useful for ssr styling

Displays the visible label text for a radio item. Renders a <span> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-radio-group-item-text<uid>
data-focusPresent when focused
data-focus-visiblePresent when focused with keyboard
data-disabledPresent when disabled
data-readonlyPresent when read-only
data-state"checked" | "unchecked"
data-hoverPresent when hovered
data-invalidPresent when invalid
data-orientationThe orientation of the item
data-ssrPresent when not rendered in the browser. Useful for ssr styling

Displays the moving selection indicator. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-radio-group-indicator<uid>
data-disabledPresent when disabled
data-orientationThe orientation of the indicator
NameTypeDescription
valuestring | nullThe current value of the radio group
setValue(value: string) => voidFunction to set the value of the radio group
clearValueVoidFunctionFunction to clear the value of the radio group
focusVoidFunctionFunction to focus the radio group
getItemState(props: ItemProps) => ItemStateReturns the state details of a radio input
getRootState() => RootStateReturns the state of the radio group
KeyDescription
TabMoves focus to either the checked radio item or the first radio item in the group.
SpaceWhen focus is on an unchecked radio item, checks it.
ArrowDownMoves focus and checks the next radio item in the group.
ArrowRightMoves focus and checks the next radio item in the group.
ArrowUpMoves focus to the previous radio item in the group.
ArrowLeftMoves focus to the previous radio item in the group.