A two-axis choice — size × frequency, room × booking length, tier × term — where every cell is an option with its price. One radio group with a single tab stop and arrow keys in both axes; unavailable cells are skipped; the chosen cell's row and column headers light up so the choice reads as coordinates. Posts as row:column.
Medium, every 2 weeks — $29 per delivery
Installation
The whole kit as one package — get updates by bumping the version. Add the styles to globals.css: @import "@vamos-ui/react/styles.css";
Usage
import { ChoiceGrid } from "@vamos-ui/react";
<ChoiceGrid
caption="Choose a size and how often it arrives"
rows={[{ id: "small", label: "Small" }, { id: "large", label: "Large" }]}
columns={[{ id: "weekly", label: "Weekly" }, { id: "monthly", label: "Monthly" }]}
cell={(row, column) => ({ price: prices[row][column], meta: "per box" })}
value={plan}
onValueChange={setPlan}
name="plan"
/>Left / right move along the row and wrap to the next row (mirrored in RTL); up / down move within the column; Home / End go to the row ends, Ctrl + Home / End to the first and last cell. Selection follows focus, as in any radio group.
Every cell's accessible name carries its row, column and price ("Medium, Weekly: $27"), so the headers are decorative for screen readers.
The grid scrolls inside itself on narrow screens rather than squeezing the prices.
Examples
API
ChoiceGrid
| Prop | Type | Default |
|---|---|---|
rows / columns{ id, label, name?, description? }. name is the plain text used in accessible names when label is not a string. | ChoiceGridAxisItem[] | — |
cell{ price?, text?, meta?, badge?, unavailable? }. null = unavailable. | (row, column) => ChoiceGridCell | null | — |
value / defaultValue / onValueChangeThe chosen cell. | { row, column } | null | — |
caption / cornerVisible caption (names the group) and the top-left header. Or pass aria-label. | ReactNode | — |
name / rowName / columnName / formHidden fields: row:column, and each axis on its own. | string | — |
formatPrice / currencyDefault: provider currency, no fraction digits. | (n) => string / string | — |
sizeTighter cells for many columns. | "sm" | "md" | "md" |
disabledEvery cell unavailable. | boolean | — |
labelsDictionary namespace "choiceGrid": cell, cellNoPrice, unavailable, cellUnavailable. | Partial<ChoiceGridLabels> | — |
choiceGridStep(available, [row, col], move)
| Prop | Type | Default |
|---|---|---|
returnsThe next selectable cell for "next" | "prev" | "up" | "down" | "rowStart" | "rowEnd" | "first" | "last". | [row, col] | null | — |