Overview
Reference usage
Responsive grid of large selectable choices with roving keyboard focus, selection state, and optional correct/incorrect/pending feedback for quiz and assessment surfaces.
Usage
Guidance
Use When
- Presenting a small fixed set of large selectable answers where all options should stay visible (quiz or assessment surfaces).
- Building a touch-friendly selector grid with stable cell dimensions that must not shift when feedback states are applied.
Avoid When
- Selecting from a long dynamic list — use combobox or select instead.
- Choosing one of two to five short values in a compact inline context — use segmented-control instead.
Card variant
variant="card" on <ChoiceGrid> draws each item as a left-aligned card instead of a centered quiz tile: a radio indicator (a checkbox indicator when multiple), an optional icon before the title, and an optional one-sentence description under it. Use it when each choice needs a sentence of explanation, such as the type of source being connected. The item's children are the title; description is a string and icon is a snippet. The selected card takes the accent border and tint, and the indicator carries the selection too, so it never rests on color alone. The grid still owns selection, roving focus and the radiogroup or group roles, and description is linked to the item with aria-describedby.
size applies to tiles only; the card variant sizes itself from its content.
Compact size
size="sm" on <ChoiceGrid> propagates to every <ChoiceGrid.Item> through context — there is no separate size prop on the item itself, so a grid's cells always size consistently. Omitting size (the default) keeps the current appearance exactly.
Sizing contract:
- Fine pointer (the default outside
(pointer: coarse)): cells match Cinder'sbuttonsmscale —block-size: var(--cinder-button-height-sm)(28px), plus thesmpadding and font-size tokens. All three shrink together: a fixed 28px cell isn't achievable by changing height alone, since the item's 2px border plus its normal (non-compact) padding already exceeds 28px on its own. - Coarse pointer: cells floor at a 44×44 CSS pixel minimum touch target instead of the 28px fine-pointer height. This floor applies to every
size="sm"cell regardless ofcolumns— whether fixed (1 | 2 | 3 | 4) or"responsive"— because a minimum touch target is an accessibility requirement, not a layout-mode-conditional feature. - States never change dimensions: selected, hover, focus, disabled, and the correct/incorrect/pending feedback states are color-only changes at every size, exactly as they are at the default size.
columns="responsive"defaultsminColumnWidthto"6rem"undersize="sm"("10rem"otherwise) — chosen so a 320px content-box-width container (<ChoiceGrid>'s own inline size, not an outer viewport before page padding or grid gaps are subtracted) fits a dense set of choices, such as 12 note names or 6 open strings, without horizontal overflow. PassminColumnWidthexplicitly and it always wins over either default.sizeis compact-only for now — only"sm"is defined. The type is its own alias (ChoiceGridSize) rather than an inline literal, so widening it to include"md"/"lg"later is additive for existing"sm"consumers, not a breaking change.
When to use
- Presenting a small fixed set of large selectable answers where all options should stay visible (quiz or assessment surfaces).
- Building a touch-friendly selector grid with stable cell dimensions that must not shift when feedback states are applied.
- Selecting from a long dynamic list — use combobox or select instead.
- Choosing one of two to five short values in a compact inline context — use segmented-control instead.
Examples
Basic single-select
A simple quiz question with four answer options and roving keyboard focus.
Cards with a description
variant="card" draws each choice as a left-aligned card with a radio indicator, an icon, a title and a one-sentence description, for choosing a source type or similar. The selected card takes the accent border and tint.
Dense phone layout
Fixed 2-column grid with compact cells — suitable for narrow mobile viewports.
Feedback states
Correct, incorrect, and pending states for quiz and assessment surfaces. Cell dimensions stay stable across states.
Multi-select
Toggle multiple answers simultaneously — useful for checkboxes presented as large tiles.
Props
Name | Type | Default | Description |
|---|---|---|---|
value bindable | text | null | The currently selected value (single-select mode). Bindable.
Pass null or omit to start with no selection. |
values bindable | string[] | [] | Currently selected values (multi-select mode). Bindable. Only used when
multiple is true — set multiple explicitly to switch modes; binding
values alone does NOT enable multi-select. |
multiple | boolean | false | When true the grid allows multiple simultaneous selections and reads/writes
values instead of value. The ARIA role switches to group (items become
checkbox); single-select uses radiogroup (items become radio). |
columns | 'responsive'1234 | 'responsive' | Column layout.
- 'responsive' — auto-fill at a minimum cell width (default).
- 1 | 2 | 3 | 4 — fixed number of columns. |
size | 'sm' | Compact-only size variant. Omitting it (the default) keeps the current
appearance. "sm" shrinks each item's block-size to Cinder's button
sm height under a fine pointer, and to a 44×44 CSS pixel minimum touch
target under a coarse pointer; it does not change selection, hover,
focus, or feedback-state styling. See the ChoiceGrid README's "Compact
size" section for the full sizing contract. | |
variant | 'tile' | 'card' | 'tile' | How items are drawn. 'tile' (the default) keeps the centered quiz tile; 'card' draws a
left-aligned card with a radio (or checkbox when multiple) indicator, so each choice can carry
an icon and a one-sentence description. Selection, roving focus and ARIA roles are identical in
both. size applies to tiles only. |
minColumnWidth | text | Minimum cell width for columns="responsive". Accepts any CSS
<length> (e.g. "12rem", "200px"). Default: "10rem", or "6rem"
when size="sm" — passing minColumnWidth explicitly always wins over
either default. | |
ariaLabel | text | Accessible label for the grid (required unless ariaLabelledby is set). | |
ariaLabelledby | text | Id of an external element that labels this grid. | |
disabled | boolean | false | Disables all items in the grid. |
children required | snippet | ChoiceGridItem children. |