# Event chip

A system event between messages, centred: an agent messaged another, renamed itself, joined the team.

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

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

```tsx
import { useState } from "react";
import {
  MessageGroup, Avatar, Bubble, EventChip, AvatarStack,
} from "@arcadia/ui";

function EventSequence() {
  const [expanded, setExpanded] = useState(false);
  return (
    <>
      <div {...sx("cmp-bar", cmp.bar, cmp.barCenter)}>
        <EventChip leading="forward" state="delivered">
          Messaged <Avatar kind="agent" avatar={BUD} name="Bud" size={16} /> Bud
        </EventChip>
        <EventChip leading="pencil">Renamed to Sweeper</EventChip>
        <EventChip leading="plus">Bud joined the team</EventChip>
        <EventChip leading={<AvatarStack size={16} items={[{ kind: "agent", id: "h", avatar: HAZEL, name: "Hazel" }, { kind: "agent", id: "b", avatar: BUD, name: "Bud" }]} />} expanded={expanded} onClick={() => setExpanded(!expanded)}>
          3 messages with Hazel and Bud
        </EventChip>
      </div>
      {expanded && <MessageGroup><Bubble>Hazel asked Bud to check the release notes.</Bubble></MessageGroup>}
    </>
  );
}
```

## Accessibility

The leading glyph is decorative; the text is the event. A chip with `onClick` is a real button, so it takes focus and Enter, and its text is its name. The state word is part of the text a screen reader reads. With `expanded` it is a disclosure button: `aria-expanded` follows it, and the chevron is decorative.

## API reference

### EventChip

- `leading` (`IconName | ReactNode`)
- `title` (`string | null`)
- `state` (`ReactNode`)
- `tone` (`"neutral" | "attention"`, default `"neutral"`)
- `variant` (`"chip" | "caption"`, default `"chip"`)
- `size` (`"caption" | "body"`, default `"caption"`)
- `enter` (`boolean`)
- `onClick` (`(e: MouseEvent<HTMLElement>) => void`)
- `expanded` (`boolean`)
- `navigates` (`boolean`)
- `rootStyle` (`RootStyle<EventChipKnobs>`)

Rest props go to `HTMLAttributes<HTMLElement>`.
