# Interaction Type Badge

An interaction's leading glyph in the workspace tables: a quiet grey puck with the type's icon (mail, phone or people), and a muted arrow in the corner for inbound or outbound. No colour: the icon says the type and the arrow says the direction. Named for screen readers, with the same words in a tooltip on hover.

- Beta: ready to use; its API can still change in a minor release.
- Category: Status & indicators

```tsx
import { InteractionTypeBadge } from "@leap-crm/design-system";
```

## Best practices

- Do: Use it as the leading glyph of an interaction: `size="sm"` in a workspace row, `md` in the interaction panel.
- Do: Pass `direction` for an email or a call, so the corner arrow shows whether the client contacted the firm or the firm contacted them.
- Do: Set `label` when the default name is not accurate, like "Email thread" for a row that holds several emails.
- Don't: Colour the puck by type or direction. The icon and the arrow carry the meaning, so it reads the same without colour.
- Don't: Use `IconTile` for an interaction's type. This badge carries the name and tooltip a tile leaves out.

## Related

- [Badge](./badge.md)
- [Tooltip](./tooltip.md)

## Examples

What the examples import:

```tsx
import { Fragment } from "react";
import { InteractionTypeBadge } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const types = ["email", "phone", "meeting"] as const;

const directions = ["inbound", "outbound", undefined] as const;
```

### Types and directions

Inbound points back in; outbound points out, both in the muted grey. Hover for the name.

```tsx
<div className="grid grid-cols-[auto_repeat(3,auto)] items-center justify-start gap-x-8 gap-y-4">
  <span />
  {["Inbound", "Outbound", "None"].map(column => (
    <span key={column} className="text-small text-neutral-text-muted">
      {column}
    </span>
  ))}
  {types.map(type => (
    <Fragment key={type}>
      <span className="text-small text-neutral-text-muted capitalize">
        {type}
      </span>
      {directions.map(direction => (
        <InteractionTypeBadge
          key={`${type}-${direction ?? "none"}`}
          type={type}
          direction={direction}
        />
      ))}
    </Fragment>
  ))}
</div>
```

### Sizes

sm (20 px) leads the workspace rows; md (32 px) heads the interaction panel.

```tsx
<div className="flex items-center gap-6">
  <InteractionTypeBadge type="email" direction="outbound" size="sm" />
  <InteractionTypeBadge type="email" direction="outbound" size="md" />
</div>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` (required) | `"email" \| "phone" \| "meeting"` |  | email, phone or meeting: the icon. |
| `direction` | `"inbound" \| "outbound"` |  | Which way it went. A meeting may have none. |
| `size` | `"sm" \| "md"` | `"sm"` | sm (20 px) in workspace rows, md (32 px) in the interaction panel. |
| `label` | `string` |  | Overrides the name, like "Email thread". |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
