Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Radio Group examples · Advanced

Radio Group with Custom Content for React

Pricing tiers as selectable cards, each with a price badge, a short description and a feature list.

Framework
UI library

A pricing choice needs more than a name. Each plan here is a card with its price in a Badge, a sentence on who it is for, and the features it includes. The whole card selects the plan, and the selected one is highlighted. In React, Base UI keeps the three cards one radio group, so only one plan can be picked.

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

Which plan starts selected?

defaultValue is pro. The values are free, pro, and enterprise, and every card is built from a list of plans at the top of the file.

How is the price placed?

The FieldTitle and the Badge share a row with justify-between. Free shows $0/mo and Enterprise shows Custom with variant secondary. Pro shows $12/mo with the default variant, so the recommended plan stands out.

Where does the feature list come from?

Each plan has a features array, rendered as a ul with list-disc, text-xs and text-muted-foreground. Pro and Enterprise list four features, Free lists three. Nothing hides a line based on the selection.

Why does the radio sit at the top of the card?

Field is horizontal, and when it holds a FieldContent it aligns its items to the start, so the radio lines up with the plan name, not the middle of the list.

What selects the plan?

The whole card. FieldLabel wraps the Field, so the name, badge, sentence and feature list all check the radio. The FieldLabel points at the item with htmlFor, and the item has the matching id.

How do I change the space between plans?

RadioGroup uses its default gap and max-w-sm. Add a gap-* class on it. The border, padding and hover of each card come from FieldLabel.