# SelectableCard

> A Card that is one selectable option; grouped into single (radio) or multiple (checkbox) sets via SelectableCardGroup.

- Status: stable
- Group: form
- Page: https://www.digitaltableteur.com/design-system/components/selectable-card
- Contract: https://www.digitaltableteur.com/contracts/v1/SelectableCard.contract.json

## When to use

Use SelectableCardGroup for visually prominent form choices, with SelectableCard children representing radio-style exclusive options or checkbox-style multiple options. The group owns the legend, value state, and error relationship.

## When not to use

- Do not nest interactive controls (buttons, links) inside a SelectableCard; the whole card is a label wrapping the input, so nested controls steal the click. Use a plain Card for action cards.
- Do not use it for navigation; selecting must not commit or route on click.

## Look-alikes

- Card: Do not nest buttons or links inside a selectable card; use Card for action-oriented content.
- CheckboxGroup: For bare text options without supporting content, use RadioGroup or CheckboxGroup.
- RadioGroup: For bare text options without supporting content, use RadioGroup or CheckboxGroup.

## Props

| Prop | Type | Default | Description | Required |
| --- | --- | --- | --- | --- |
| `value` | `string` | none | Submitted value / selection key. | Yes |
| `disabled` | `boolean` | `false` | Per-card disable; the choice stays visible. | No |
| `selected` | `boolean` | none | Standalone selected state when used outside a SelectableCardGroup. | No |
| `onSelectedChange` | `(selected: boolean) => void` | none | Standalone change handler when used outside a SelectableCardGroup. | No |

## Variants

No variant dimensions and no props with a fixed set of values.

## Invalid combinations

The contract records no invalid combinations.

## Keyboard

| Key | Behaviour |
| --- | --- |
| Tab | Moves focus into the group. |
| Arrow keys | Move within a single-select set (native radio) |
| Space | Toggles the focused option. |

## Rules

Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.

| Level | Rule | How it is checked |
| --- | --- | --- |
| MUST | ARIA: Group renders a fieldset with a legend for the accessible name. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Each card is a label wrapping a native radio/checkbox input. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Error announces via role=alert and sets aria-invalid on the group. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by `npm run test:stories:matrix:ci`. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by `npm run test:stories:matrix:ci`. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by `npm run test:stories:hc`. |
| MUST | Every documented keyboard interaction works as specified. | Not yet verified: no evidence record. WCAG 2.1.1, 2.1.2. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-11-04. |
| SHOULD | Write the group legend as the question and keep each card title short and scannable. | Not stated in the contract. |
| SHOULD | Use single selection for a few rich exclusive options and multiple selection for independent add-ons. | Not stated in the contract. |
| SHOULD | For one standalone toggle outside a group, control selected and onSelectedChange directly. | Not stated in the contract. |
| SHOULD NOT | Do not nest buttons or links inside a selectable card; use Card for action-oriented content. | Not stated in the contract. |
| SHOULD NOT | For bare text options without supporting content, use RadioGroup or CheckboxGroup. | Not stated in the contract. |

## Install and import

- Install: `npm install @digitaltableteur/react` (version 0.9.1, restricted access on npm).
- Import: `import { SelectableCard } from "@digitaltableteur/react";`
- Entry point: `@digitaltableteur/react/forms` exports it too.
- Styles: import `@digitaltableteur/react/style.css` once at the app boundary.
- Also available as the custom element `<dt-selectable-card>`; see the custom elements manifest.

## Links

- Machine-readable contract (Design System Contract 1.0): https://www.digitaltableteur.com/contracts/v1/SelectableCard.contract.json
- Markdown version of this page: https://www.digitaltableteur.com/design-system/components/selectable-card.md
- Component index as JSON: https://www.digitaltableteur.com/design-system/components.json
- All components: https://www.digitaltableteur.com/design-system/components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.
