# Choice list

One question and a few answers, each with a line of what it means, one always chosen, on the platform's radios.

Live variants: https://design.arcadia.is/components/choice-list

```tsx
import { ChoiceList } from "@arcadia/ui";
```

Choose a team role. The description stays readable while the check moves to the chosen answer.

```tsx
import { useState } from "react";
import { ChoiceList } from "@arcadia/ui";

function MemberRole() {
  const [role, setRole] = useState<Role>("member");
  return (
    <div {...sx("cmp-form", cmp.form)}>
      <ChoiceList label="Role" items={ROLES} value={role} onValueChange={setRole} />
    </div>
  );
}
```

## Accessibility

A `fieldset` named by its `legend`, the question, and in it the platform's own radios under one `name`, each laid clear over its mark: they take the focus, the press and the keys, and the kit draws the mark. Each radio is named by its answer's name and described by its line, so it reads "Member, radio button, 2 of 2, selected, Works in the team's boards and agents in every product". The list is one Tab stop, on the answer chosen, and the arrow keys move and choose as the platform's do, past a disabled answer.

Under forced colours the marks keep their shapes in the system's ink, the chosen one in its highlight, and a disabled answer takes the system's grey.

- Tab: Moves to the answer chosen, then to the next control
- ↑ + ↓ + ← + →: Chooses the previous or the next answer
- Space: Chooses the answer in focus

## API reference

### ChoiceList

- `label` (`ReactNode`, required): The question, the fieldset's legend ("Role").
- `items` (`readonly ChoiceItem<V>[]`, required): The answers, in order.
- `value` (`V`): Controlled value. One answer is always chosen.
- `defaultValue` (`V`): Initial value when uncontrolled, and what a form's reset puts back. Default the first answer that is not disabled.
- `onValueChange` (`(value: V, details: { event: Event }) => void`): Called with the value chosen, by a press or by an arrow key.
- `name` (`string`): The radios' name, which a form sends with the value; one of its own when left out.
- `form` (`string`): The form the radios belong to, where they stand outside it.
- `disabled` (`boolean`, default `false`): Disables every answer and dims the question.
- `rootStyle` (`ChoiceListStyle`): Typed StyleX override on the fieldset: layout and the `--choice-*` knobs.

Rest props go to `<fieldset>` props.
