ChoiceCard
ChoiceCard — one option as a card a person picks (a plan, a class, an answer with a picture): the twin of genesis-ui-native's NativeChoiceCard, with the same `title`, `description`, `media`, `multiple`, `invalid` and `disabled`. One of several (the default) is a radio built on the RadioGroup's item, so it goes in a `RadioGroup` with a label: the group is one tab stop, the arrow keys move the choice, and the group's `value` is the chosen card's. With `multiple` it is a checkbox with its own `selected` and `onSelectedChange`; put those in an element with `role="group"` and a label. ```tsx <RadioGroup aria-label="Plan" value={plan} onValueChange={setPlan}> <ChoiceCard value="monthly" title="Monthly" description="$20 a month" /> <ChoiceCard value="yearly" title="Yearly" description="$200 a year" /> </RadioGroup> ``` The card's surface is the Card's (`bg-card`, `border`, `rounded-lg`).
packages/ui/src/components/ui/choice-card.tsx
@marktiderman/genesis-uiimport { ChoiceCard } from "@marktiderman/genesis-ui";react-docgen-typescript.ChoiceCard
ChoiceCard — one option as a card a person picks (a plan, a class, an answer with a picture): the twin of genesis-ui-native's NativeChoiceCard, with the same `title`, `description`, `media`, `multiple`, `invalid` and `disabled`. One of several (the default) is a radio built on the RadioGroup's item, so it goes in a `RadioGroup` with a label: the group is one tab stop, the arrow keys move the choice, and the group's `value` is the chosen card's. With `multiple` it is a checkbox with its own `selected` and `onSelectedChange`; put those in an element with `role="group"` and a label. ```tsx <RadioGroup aria-label="Plan" value={plan} onValueChange={setPlan}> <ChoiceCard value="monthly" title="Monthly" description="$20 a month" /> <ChoiceCard value="yearly" title="Yearly" description="$200 a year" /> </RadioGroup> ``` The card's surface is the Card's (`bg-card`, `border`, `rounded-lg`).
| Prop | Type | Default | Description |
|---|---|---|---|
| onSelectedChange* | (selected: boolean) => void | — | Called when it is pressed (Space, or a click), with the new state. |
| selected* | boolean | — | |
| title* | ReactNode | — | |
| value* | string | — | This card's value in its RadioGroup. |
| className | string | — | |
| description | ReactNode | — | A second line under the title, muted. |
| disabled | boolean | — | |
| invalid | boolean | — | The question still needs an answer: a destructive border, and said to screen readers. |
| media | ReactNode | — | Left of the text: a thumbnail, an icon. |
| multiple | boolean | — | |
| testID | string | — |