Forms
Choice Card
Radio group rendered as selectable cards for roles, plans and onboarding choices.
react-aria-components
Preview
Your role
"use client";
import { Briefcase, Target, Users } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { ChoiceCard, ChoiceCardGroup } from "@/components/ui/choice-card";
export default function Example() {
return (
<ChoiceCardGroup label="Your role" defaultValue="ae" className="w-full max-w-md">
<ChoiceCard value="ae" icon={<Briefcase />} title="Account Executive" description="Work deals and book meetings." />
<ChoiceCard value="sdr" icon={<Target />} title="SDR / BDR" description="Prospect and qualify leads." meta={<Badge size="sm" tone="accent">Popular</Badge>} />
<ChoiceCard value="leader" icon={<Users />} title="Sales leader" description="Set goals and coach the team." />
</ChoiceCardGroup>
);
}Installation
Components are copied into your project — no runtime package.
Install the following dependencies:
terminalnpm install react-aria-componentsCreate a
choice-card.tsxfile and paste the following code into it.src/components/ui/choice-card.tsx"use client"; import type { ReactNode } from "react"; import { Radio, RadioGroup, type RadioGroupProps } from "react-aria-components"; import { cx } from "@/utils/cx"; import { Label } from "./field"; export interface ChoiceCardGroupProps extends Omit<RadioGroupProps, "className" | "children"> { label?: string; columns?: 1 | 2 | 3; className?: string; children: ReactNode; } /** Radio group rendered as selectable cards — for plans, roles and onboarding choices. */ export function ChoiceCardGroup({ label, columns = 1, className, children, ...props }: ChoiceCardGroupProps) { return ( <RadioGroup {...props} className={cx("flex flex-col gap-2", className)}> {label && <Label>{label}</Label>} <div className={cx("grid gap-3", columns === 2 && "sm:grid-cols-2", columns === 3 && "sm:grid-cols-3")}>{children}</div> </RadioGroup> ); } export interface ChoiceCardProps { value: string; title: ReactNode; description?: ReactNode; icon?: ReactNode; /** Right-aligned extra, e.g. a price or badge. */ meta?: ReactNode; isDisabled?: boolean; } export function ChoiceCard({ value, title, description, icon, meta, isDisabled }: ChoiceCardProps) { return ( <Radio value={value} isDisabled={isDisabled} className={cx( "group flex cursor-default items-start gap-3 rounded-md bg-surface p-4 outline-none ring-1 ring-inset ring-line transition-[box-shadow,background]", "data-hovered:bg-subtle data-selected:bg-surface data-selected:shadow-[inset_0_0_0_1.5px_var(--color-accent),var(--shadow-card)] data-focus-visible:shadow-[inset_0_0_0_1.5px_var(--color-accent),var(--shadow-focus)]", "data-disabled:opacity-50", )} > {icon && ( <span className="flex size-9 shrink-0 items-center justify-center rounded-[10px] bg-surface text-fg-secondary shadow-button group-data-selected:bg-accent-soft group-data-selected:text-accent group-data-selected:shadow-none [&_svg]:size-4"> {icon} </span> )} <span className="min-w-0 flex-1"> <span className="block text-base font-medium text-fg">{title}</span> {description && <span className="mt-0.5 block text-sm text-fg-secondary">{description}</span>} </span> {meta} <span className="mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border border-line-strong bg-surface group-data-selected:border-accent group-data-selected:bg-accent"> <span className="size-1.5 scale-0 rounded-full bg-white transition-transform group-data-selected:scale-100" /> </span> </Radio> ); }Create a
field.tsxfile and paste the following code into it.src/components/ui/field.tsx"use client"; import type { ReactNode } from "react"; import { FieldError, Label as AriaLabel, Text } from "react-aria-components"; import { cx } from "@/utils/cx"; /** Shared field chrome: 40px tall, radius 12, 1px border-strong, accent border + 3px ring on focus. */ export const fieldBase = "w-full rounded-md border border-line-strong bg-surface text-base text-fg outline-none transition-[border,box-shadow] " + "placeholder:text-fg-muted data-hovered:border-fg-disabled " + "data-focused:border-accent data-focused:shadow-focus data-focus-within:border-accent data-focus-within:shadow-focus " + "data-invalid:border-error data-invalid:data-focused:shadow-focus-error " + "data-disabled:border-line data-disabled:bg-subtle data-disabled:text-fg-disabled data-disabled:placeholder:text-fg-disabled"; export function Label({ className, children }: { className?: string; children: ReactNode }) { return <AriaLabel className={cx("text-sm font-medium text-fg", className)}>{children}</AriaLabel>; } export function Description({ children }: { children: ReactNode }) { return ( <Text slot="description" className="text-sm text-fg-muted"> {children} </Text> ); } export function ErrorMessage({ children }: { children?: ReactNode }) { return <FieldError className="text-sm text-error-text">{children}</FieldError>; }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.