← All proposals

Card Select

Add a shadow prop to the PDS Card Select.

Extends a PDS componentOpen in Storybook

proposals/CardSelect/CardSelect.mdx44 lines · View on GitHub
import { Canvas, Controls, Meta, Title } from '@storybook/addon-docs/blocks';

import * as CardSelectStories from './CardSelect.stories';

<Meta of={CardSelectStories} name='Usage' />

<Title />

## Purpose

The PDS Card Select with a `shadow` prop, for dense layouts and surfaces where the card drop shadow is too heavy.

## Usage

- Use it, like the PDS Card Select, for one choice from a set where each option is a card. Use `shadow={false}` only when the shadow is too heavy: dense layouts, or surfaces that already carry elevation.
- Not for choosing more than one option (use checkboxes), and not for a plain list of short options (use a radio group).
- `shadow={true}` (default) is the unchanged PDS Card Select.
- `shadow={false}` removes the drop shadow. An unselected card has a border in the input border color. On hover the card background gets a tint, the same as the secondary Button hover. The selected card is marked by the check indicator; with `showIndicator={false}` it is marked by the focus ring instead.
- Everything else is the PDS Card Select: `options` (`label`, `value`, composable `children`), `defaultValue`, `onChange`, `background`, `size`, `layout`, `padding`, `imageVariant`, `showIndicator` and `showCardLabels`.
- It is built on the published Card Select, so the radio inputs, keyboard focus ring and labels come with it.

## Accessibility

- It is the PDS Card Select: a `fieldset` whose `legend` is the `label`, with one native radio input per card and the card label as its accessible name. A screen reader announces the group name, the option and its checked state.
- Keyboard: Tab moves into the group, the arrow keys move the selection between cards, and a focus ring is drawn on the focused card in both modes. `shadow` does not change any of this.
- Selected state: with `shadow={false}` the card is marked by the check indicator, or by the focus-color ring when `showIndicator={false}`. These are visual marks only; assistive technology reads the radio state.
- The unselected border uses the same color token as the PDS inputs, which is low contrast against a white surface (about 1.45:1 in light, computed from the token). The selected state does not rely on it.
- `label` is required and is the group name; with `showCardLabels={false}` each card's `label` stays as its accessible name. Provide them translated. The Storybook a11y panel was last run on 2026-11-03 with no violations; it was not re-run for this page.

## Implementation

See the table below for the available props. The stories show the shadow on and off, with and without the radio indicator, and at the large size.

<hr />

<Canvas of={CardSelectStories.WithShadow} />
<Controls of={CardSelectStories.WithShadow} />

<Canvas of={CardSelectStories.WithoutShadow} />

<Canvas of={CardSelectStories.WithoutShadowOrIndicator} />

<Canvas of={CardSelectStories.WithoutShadowLarge} />