shadcn.io is not affiliated with official shadcn/ui
Radio Group examples · Layout
Radio Group in Grid for React
Six radio options in a two-column grid, for a longer single choice that should not run down the page.
Six options stacked in one column take a lot of height. This group sets two grid columns, so the same six choices fill three rows. Use it for categories, filters, or settings with many mutually exclusive options, and switch the column count by breakpoint if the labels grow. In React, Base UI still treats it as one group.
Preview
Installation
FAQ
How do I get two columns?
RadioGroup is already a grid, and grid-cols-2 gives it two columns. Six items fill three rows: Option 1 beside Option 2, then 3 beside 4, then 5 beside 6. Change grid-cols-2 for another count, such as grid-cols-1 sm:grid-cols-3.
Which option starts selected?
defaultValue is grid-1, the same string as the first item's value. The values run from grid-1 through grid-6 and come from a list at the top of the file.
Why does the label text select the radio?
The text is the item's label, so clicking it checks that item. Each RadioGroupItem has an id, and FieldLabel points at it with htmlFor.
Which way do the arrow keys move?
They follow the items in source order: Option 1, Option 2, Option 3, and so on. That is across the row, then the next row. Space checks the focused item.
Related
- Basic Radio GroupA vertical radio group of three options
- Horizontal Radio GroupA radio group with its three options in a
- Radio Group with CardsPlan options as bordered cards, where
- Radio Group in FormA required notification setting in a form
- Radio Group with Custom ContentPricing tiers as selectable cards, each
- Radio Group with IconsPayment method options with an icon