Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Radio Group examples · Form

Radio Group with Disabled States for React

Three radio groups compared: all enabled, all disabled, and one disabled option in an enabled group.

Framework
UI library

Disabled radios show a choice that exists but is not available right now, instead of hiding it. This example puts the three cases one under another, each named by a FieldLegend: a normal group, a group that is disabled as a whole, and a group with one disabled option. In React, Base UI skips disabled items and keeps their value.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How is the middle group fully disabled?

That RadioGroup is disabled and sets defaultValue to option-3, so Disabled and selected stays the value while both items are off. The prop is disabled.

How is a single option disabled?

The third group sets defaultValue to option-5, and the item with the value option-6 is disabled. The Enabled item in that group stays usable. Set disabled on that RadioGroupItem.

What does the first group show?

It has no disabled prop. defaultValue is option-1, labeled Enabled and selected, and the second item is labeled Enabled.

Why are the disabled labels faded?

Each disabled option sits in a Field with data-disabled, and the label fades with it, so the text matches the dimmed radio. Leave data-disabled off and the label stays at full strength.

Can the selected item be disabled?

The middle group does that: its value is option-3 on a group that is itself disabled. The mixed group selects the enabled item, option-5, and leaves option-6 disabled.

What happens to keyboard use when an item is disabled?

A disabled item is skipped by the arrow keys and cannot be checked. The fully disabled group cannot be reached with Tab at all, and the other two use the usual keys.