Introducing PrimeReact v11-alpha 🎉Discover Now
styledForm

RadioButton

RadioButton is an extension to standard radio button element with theming.

Select a deployment environment:
preview

Usage#

import { RadioButtonGroup } from '@primereact/ui/radiobuttongroup';
import { RadioButton } from '@primereact/ui/radiobutton';
<RadioButtonGroup>
    <RadioButton.Root>
        <RadioButton.Box>
            <RadioButton.Indicator />
        </RadioButton.Box>
    </RadioButton.Root>
</RadioButtonGroup>

Examples#

Basic#

Selects a single option from a group of mutually exclusive choices.

basic-demo

Group#

Use the RadioButtonGroup component with value and onValueChange props to control the selected state of radio buttons.

group-demo

Dynamic#

RadioButtons can be generated using a list of values.

dynamic-demo

Card#

RadioButtons can be displayed in a card style.

Choose a plan:
card-demo

Sizes#

Use the size property to change the size of a radio button.

sizes-demo

Filled#

Specify the variant="filled" property to display the component with a higher visual emphasis than the default outlined style.

filled-demo

Disabled#

When the disabled property is present, the element cannot be edited and focused.

disabled-demo

Invalid#

Invalid state is displayed using the invalid property to indicate a failed validation. This style is useful when integrating with form validation libraries.

invalid-demo

Conditional Indicator#

RadioButton.Indicator accepts a match prop to conditionally render based on the radio button state. When match is set, the indicator only mounts when the current state matches the given value.

<RadioButton.Root>
    <RadioButton.Box>
        <RadioButton.Indicator match="checked">
            <Check />
        </RadioButton.Indicator>
        <RadioButton.Indicator match="unchecked">
            <Circle />
        </RadioButton.Indicator>
    </RadioButton.Box>
</RadioButton.Root>

Available values: checked, unchecked. Without the match prop, the indicator renders in all states.

API#

Sub-Components#

See Primitive API for RadioButtonRoot, RadioButtonBox, RadioButtonIndicator, and RadioButtonGroup component documentation.

Hooks#

See Headless API for useRadioButton and useRadioButtonGroup hook documentation.

Accessibility#

See RadioButton Primitive for WAI-ARIA compliance details and keyboard support.