# Reaction picker

A compact picker for the product's reactions, the reader's own pressed.

Live variants: https://design.arcadia.is/components/reaction-picker

```tsx
import { ReactionPicker, pickerIndex } from "@arcadia/ui";
```

```tsx
import { MessageGroup, Bubble, ReactionPicker } from "@arcadia/ui";

function ReactionPickerConversation() {
  const { given, toggle } = ReactionPickerUseReactions<Reaction>("thumbs_up");
  return (
    <div {...sx("cmp-reaction-picker-stack", ReactionPickerStyles.stack)}>
      <MessageGroup side="start" author="nora">
        <Bubble side="start">Pick one for this message. Yours stay pressed.</Bubble>
      </MessageGroup>
      <ReactionPicker choices={REACTION_SET} given={given} onChoose={toggle} />
    </div>
  );
}
```

## Keyboard

- Tab: One stop for the toolbar, on the first choice or the last one focused. With fewer than three choices, Tab reaches each button.
- ← + →: Move between choices in order, wrapping at either end.
- ↑ + ↓: Move to the same column in the row above or below, if that choice exists.
- Home + End: The first or the last cell.
- Enter + Space: Gives the reaction or takes it back.
- Esc: In its popover, closes it; focus goes back to React.

## Accessibility

With three or more choices the picker is a horizontal toolbar; otherwise it is a group. Both are named Reactions by default (`label`). Each button takes its choice's `label` and uses `aria-pressed` to mark a reaction the reader gave.

## API reference

### ReactionPicker

- `choices` (`readonly ReactionChoice<N>[]`, required): The product's choices, in its order, with the glyph and skin tone it wants to show.
- `given` (`Iterable<N>`): The names the reader has already given: those cells are pressed.
- `onChoose` (`(name: N) => void`, required): Called with a cell's name when the reader presses it, given or not.
- `columns` (`number`, default `5`): Preferred cells to a row, fewer where space is tight.
- `label` (`string`, default `"Reactions"`): The picker's accessible name.
- `rootStyle` (`RootStyle`): Typed StyleX override: where it sits.
