Skip to Content
zjkm-ui
Components

Radio Cards

Options as selectable cards.

Plan
Props
<RadioCards legend="Plan" options={plans} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/radio-cards.json
import { 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

PropTypeDefaultDescription
legendstringNames the group.
options{ value, title, description? }[]The choices.
namestringForm field name.
defaultValuestringthe firstStarting choice.
onChange(value: string) => voidCalled when the choice changes.
classNamestringClasses for the wrapper.

With reduced motion, the highlight changes without a transition.

On this page