Components
Radio Cards
Options as selectable cards.
<RadioCards legend="Plan" options={plans} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/radio-cards.jsonimport { RadioCards } from "@/components/radio-cards"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Options as cards with a title and a description. They're native radios in a fieldset, so arrow keys move between them and the choice submits with a form when you set name.
import { RadioCards } from "@/components/radio-cards";
const plans = [
{ value: "hobby", title: "Hobby", description: "Free, for side projects" },
{ value: "team", title: "Team", description: "$12 per seat a month" },
];
export function Plan() {
return <RadioCards legend="Plan" name="plan" options={plans} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
legend | string | Names the group. | |
options | { value, title, description? }[] | The choices. | |
name | string | Form field name. | |
defaultValue | string | the first | Starting choice. |
onChange | (value: string) => void | Called when the choice changes. | |
className | string | Classes for the wrapper. |
With reduced motion, the highlight changes without a transition.