# Record Chip

A link to a record, like a contact, a matter, a folder or a LEAP card: a small square chip (24 px, 4 px radius). Values and labels use the round Tag instead.

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

```tsx
import { RecordChip, RecordChipGroup } from "@leap-crm/design-system";
```

## Best practices

- Do: Use it to point at another record, like a matter's client or a linked contact, with `href` so the name opens the record.
- Do: Pass an `icon` for the record's kind, like a person for a contact and a briefcase for a matter, so two records with similar names are told apart.
- Do: Wrap chips that come and go in `RecordChipGroup`, so a removed chip fades and the row closes up behind it.
- Do: Let long names truncate. The name goes through `Truncate`, so the full name shows on hover in a narrow panel.
- Don't: Use it for a value or a label, like a practice area. Use the round `Tag`, so a link to a record and a label never look alike.

## Keyboard

| Keys | What they do |
| --- | --- |
| Enter | Follows a chip that is a link. |
| Enter, Space | Presses a chip's button, like its remove ×. |

## Related

- [Avatar](./avatar.md)
- [Badge](./badge.md)
- [Text Link](./text-link.md)

## Examples

What the examples import:

```tsx
import { Briefcase, Building2, FolderClosed, User } from "lucide-react";
import { useState } from "react";
import { RecordChip, RecordChipGroup } from "@leap-crm/design-system";
```

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

```tsx
function RemovableChips() {
  const [people, setPeople] = useState(["Ada Hartley", "Ben Okafor"]);
  return (
    <div className="flex flex-wrap items-center gap-2">
      <RecordChipGroup>
        {people.map(name => (
          <RecordChip
            key={name}
            label={name}
            icon={<User />}
            onRemove={() =>
              setPeople(current => current.filter(person => person !== name))
            }
          />
        ))}
      </RecordChipGroup>
      {people.length === 0 && (
        <span className="text-small text-neutral-text-muted">No one</span>
      )}
    </div>
  );
}
```

### Kinds

A 14 px icon says what kind of record it is. With href the name is a link, and its underline fades in on hover.

```tsx
<div className="flex flex-wrap gap-2">
  <RecordChip label="Ada Hartley" icon={<User />} href="/record-chip" />
  <RecordChip
    label="Citizen Holdings"
    icon={<Building2 />}
    href="/record-chip"
  />
  <RecordChip label="Smith v Jones" icon={<Briefcase />} />
  <RecordChip label="Correspondence" icon={<FolderClosed />} />
  <RecordChip label="No icon" />
</div>
```

### Removable

The 20 px remove button sits inside the chip's end; its target reaches 24 px. In a RecordChipGroup, a removed chip fades and the row closes up behind it, so the others slide rather than jump.

```tsx
<RemovableChips />
```

### Long names

A long name truncates inside its container.

```tsx
<div className="w-48">
  <RecordChip
    label="Estate of the late Margaret Anne Citizen"
    icon={<Briefcase />}
    onRemove={() => undefined}
  />
</div>
```

## Props

### RecordChip

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `string` |  | The record's name, like a contact or a matter. |
| `icon` | `ReactNode` |  | A 14 px icon for the record's kind. |
| `href` | `string` |  | Makes the chip a link to the record. |
| `onRemove` | `() => void` |  | Shows a remove × after the name. Called when it's pressed. |
| `removeLabel` | `string` |  | The remove button's name. "Remove <label>" by default. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### RecordChipGroup

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` (required) | `ReactNode` |  | The chips, each with a key, like a matter's people. One added or removed opens or closes its own space. |
| `gap` | `RowGap` | `8` | The gap between chips, in px: 4, 6 or 8 (the default). |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
