Radio cards
Updated
RadioCards is a radio group drawn as cards, for a choice that needs a line of detail, like a plan or a data region. The native radios keep arrow-key moves and form values; hover casts the dithered shadow and the checked card keeps it under a heavier frame, or with variant="solid" fills with ink or a checkedColor of your own. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.
Example
import "@/components/dithercharts/controls.css"
import { RadioCards } from "@/components/dithercharts/radio-cards"
<RadioCards
legend="Data region"
name="region"
defaultValue="us-east"
onValueChange={(region) => setRegion(region)}
options={[
{ value: "us-east", label: "US East", description: "Virginia, lowest latency for the Americas" },
{ value: "eu-west", label: "EU West", description: "Ireland, keeps data in the EU" },
]}
/>
// Fill the checked card instead of doubling its frame, in ink or any CSS color.
<RadioCards legend="Billing" variant="solid" checkedColor="#2f6fde" options={billing} />Install
Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.
npx dithercharts add radio-cards
Props
It renders a native element, so every other attribute that element takes passes through.
| Prop | Type | Default | Description |
|---|---|---|---|
| legendrequired | Type ReactNode | Default – | The group's caption, read before its cards. |
| optionsrequired | Type readonly RadioCardOption[] | Default – | |
| value | Type string | Default – | The checked card's value, for a controlled group; pair it with onValueChange. |
| defaultValue | Type string | Default – | The card checked at first, for an uncontrolled group. |
| onValueChange | Type (value: string) => void | Default – | |
| name | Type string | Default a generated id | The radios' form field name. |
| disabled | Type boolean | Default false | Disables every card. |
| variant | Type "outline" | "solid" | Default "outline" | How the checked card stands out: "outline" doubles its frame, "solid" fills it and turns its text paper. |
| checkedColor | Type string | Default – | The checked card's fill in the "solid" variant, as any CSS color. Default the ink color, with paper text. A color of your own gets white text in both themes; for a light fill, set --dc-radio-card-on-fill to a dark color. |
| className | Type string | Default – |

