shadcn.io is not affiliated with official shadcn/ui
Radio Group examples · Advanced
Radio Group with Icons for React
Payment method options with an icon before each label, so the choices are easier to scan.
Payment methods, delivery options and account types are quicker to scan with a picture. Each option here pairs a Lucide icon with its name: a credit card, a wallet, a phone. The icon sits inside the label, so clicking it checks the radio. In React, Base UI handles the group as usual.
Preview
Installation
FAQ
Which option starts selected?
defaultValue is card, the Credit Card option. The other values are wallet and mobile.
Where do the icons sit?
Each icon is inside the label, before the text, at size-4. The label is a flex row with a gap, so the icon and the text stay apart. Credit Card uses CreditCardIcon, Digital Wallet WalletIcon, and Mobile Payment SmartphoneIcon.
Does the icon need its own name?
No. Each icon has aria-hidden, and the text next to it names the option. The icon and text are inside FieldLabel, which points at the item's id with htmlFor.
How do I change the space beside the radio?
Field sets the gap between the radio and the label. Pass a gap-* class to the Field.Change size-4 on the icons to resize them.Related
- Basic Radio GroupA vertical radio group of three options
- Radio Group with DescriptionsA radio group with a line of muted text
- Radio Group with Custom ContentPricing tiers as selectable cards, each
- Radio Group with CardsPlan options as bordered cards, where
- Radio Group in FormA required notification setting in a form
- Radio Group with Disabled StatesThree radio groups compared: all enabled