Menu

Selection card

Radio / checkbox cards. 2 types × 4 states.

Installation

$ npx uix-ui@latest add selection-card

This copies the file into components/ui/selection-card.tsx in your project. npx shadcn@latest add @uix/selection-card works too.

Usage

selection-card.tsx
import { SelectionCard } from "@/components/ui/selection-card";

<div style={{ width: 360, display: "grid", gap: 12 }} role="radiogroup" aria-label="Tea club plan">
  <SelectionCard name="plan" checked={plan === "monthly"} onChange={() => setPlan("monthly")} title="Monthly tin" description="One 250g tin each month." price="৳480 / month" />
  <SelectionCard name="plan" checked={plan === "yearly"} onChange={() => setPlan("yearly")} icon={<Zap />} title="Yearly club" description="Twelve tins, one free." price="৳5,280 / year" />
</div>

Props

PropTypeDefaultDescription
typeradio | checkbox"radio"
titleReact.ReactNode–
descriptionReact.ReactNode–
priceReact.ReactNode–Price or other fact under the description.
iconReact.ReactNode–Replaces the default icon in the round badge.

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
esc

↑↓ to navigate · ↵ to select · esc to close