ComponentsPickers

Choice grid

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.

WAI-ARIA radio group components/choice-grid.tsxtheme · material · accent · density · font
Choose a size and how often it arrives

Medium, every 2 weeks — $29 per delivery

Installation

$ pnpm add @vamos-ui/react

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

Unavailable cells, posted

cell returns null where there is no offer; the arrow keys skip it. name posts row:column, rowName and columnName post each axis.

API

ChoiceGrid

PropTypeDefault
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 / onValueChange
The chosen cell.
{ row, column } | null—
caption / corner
Visible caption (names the group) and the top-left header. Or pass aria-label.
ReactNode—
name / rowName / columnName / form
Hidden fields: row:column, and each axis on its own.
string—
formatPrice / currency
Default: provider currency, no fraction digits.
(n) => string / string—
size
Tighter cells for many columns.
"sm" | "md""md"
disabled
Every cell unavailable.
boolean—
labels
Dictionary namespace "choiceGrid": cell, cellNoPrice, unavailable, cellUnavailable.
Partial<ChoiceGridLabels>—

choiceGridStep(available, [row, col], move)

PropTypeDefault
returns
The next selectable cell for "next" | "prev" | "up" | "down" | "rowStart" | "rowEnd" | "first" | "last".
[row, col] | null—