# Reaction chip

One reaction under a message: the emoji, up to three pictures of who gave it, the count past them and the reader's own on the quiet neutral fill; who gave it on hover.

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

```tsx
import {
  ReactionChip, ReactionChips, reactionName, reactionWho,
} from "@arcadia/ui";
```

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

function ReactionChipConversation() {
  const [theirs, toggleTheirs] = useReactions([{ name: "thumbs_up", who: ["Scout for maya", "you", "nora"] }, { name: "thanks", who: ["nora"] }]);
  const [picture, togglePicture] = useReactions([{ name: "fire", who: ["Scout for maya"] }]);
  return (
    <div {...sx("cmp-reaction-chip-stream", ReactionChipStyles.stream)}>
      <MessageGroup side="start" author="maya" meta={<Chips list={theirs} toggle={toggleTheirs} />}>
        <Bubble side="start">The chips are in. Press one to put your reaction on or take it back.</Bubble>
      </MessageGroup>
      <MessageGroup side="end" meta={<Chips list={picture} toggle={togglePicture} side="end" />}>
        <MessageParts side="end">
          <ImageAlbum side="end" images={[HARBOUR]} />
          <Bubble side="end">The harbour at noon.</Bubble>
        </MessageParts>
      </MessageGroup>
    </div>
  );
}
```

## Keyboard

- Tab: Each chip is a stop; its tooltip, who gave it, shows on focus.
- Enter + Space: Puts your reaction on or takes it back.
- Esc: Hides the tooltip.

## Accessibility

Each chip is a toggle button named by its glyph's words and its count ("Thumbs up, 3"), `aria-pressed` saying whether the reaction is yours; the glyph, the pictures and the figure are hidden from assistive tech. Who gave it is the tooltip's line, which the button carries as its description. On a device that cannot hover the tooltip does not show: a product that needs the names there lists them in the message's menu. The row is a group named Reactions. Under forced colours your reaction takes the system's highlight, as a pressed chip does.

## API reference

### ReactionChip

- `glyph` (`string`, required): The system's own emoji, drawn as text at the chip's style (`👍`).
- `label` (`string`, required): What a reader hears for the glyph (`Thumbs up`).
- `count` (`number`, required): How many gave it: the figure shows above one, and always when more gave it than the pictures show.
- `mine` (`boolean`, default `false`): The reader gave it: the chip stands on the quiet raised fill (`--fill-3`) in the primary ink, its glyph whole; reactions only others gave stay in the neutral outline.
- `who` (`readonly string[]`): Who gave it, in the product's order ("you" among them where the reader did): the chip's tooltip, under the pointer and on keyboard focus.
- `reactors` (`readonly AvatarStackItem[]`): Who gave it, as 16px pictures beside the glyph (at most three); past them the count stands instead. Left out, the chip shows the glyph and its count alone.
- `onToggle` (`(mine: boolean) => void`): A press: the product puts the reaction on (`true`) or takes it back (`false`). Without it the chip is still a toggle that tells its state, and the product handles `onClick`.
- `readOnly` (`boolean`, default `false`): Shown where the reader cannot react (for example, their own message): static outline chip, not a toggle button.
- `buttonProps` (`ButtonMarks`): The product's own marks on the chip's own element, the button a press hits: its `data-*` only.
- `rootStyle` (`ChipStyle`): Typed StyleX override: where it sits and the `--chip-*` knobs.

### ReactionChips

- `side` (`"start" | "end"`, default `"start"`): The message's side: the chips start on its edge.
- `label` (`string`, default `"Reactions"`): The group's name for a reader.
- `rootStyle` (`RootStyle`): Typed StyleX override: layout.
- `children` (`ReactNode`, required): `ReactionChip`s, in the product's order. Each keeps its own slot: one added opens the row and one taken back shuts, while the rest stand where they are.

Rest props go to `<div>` props.
