# Note tile

One note in the workspace grid. Every tile keeps the same slots in the same places: kind and date, a one-line title, three muted lines, then who wrote it, with comment and attachment counts only when there are any. A small Firm Pilot mark after the name means Firm Pilot wrote it for that person. A chip says where the note belongs only when that isn't the page it's on.

- Beta: ready to use; its API can still change in a minor release.
- Category: Patterns · Notes & tasks

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

## Best practices

- Do: Set `selected` on the tile whose note is open beside the grid. Its focus-blue border shows which, and screen readers hear it as pressed.
- Do: Set `context` only when the note belongs elsewhere: its matter on a contact, its contact on an opportunity.
- Do: Set `viaFirmPilot` on the `author` when Firm Pilot wrote the note for someone, so the small Firm Pilot mark follows their name.
- Don't: Set `highlighted` on a note someone just wrote. Set it only when they were taken to the note, from a notification, a link or search.
- Don't: Put a pin, menu or link on the tile. The whole tile is one button that opens the note; its actions live in `NotePanel`.

## Keyboard

| Keys | What they do |
| --- | --- |
| Enter, Space | Open the note, when the tile does something. |

## Related

- [Note grid](./note-grid.md)
- [Note panel](./note-panel.md)
- [Card](./card.md)

## Examples

What the examples import:

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

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

```tsx
const call = {
  kind: "call" as const,
  date: "21 Nov",
  title: "Vendor wants a 60-day settlement",
  excerpt:
    "Agent called: the vendor prefers 60 days and will take 45 with a 10% deposit. Rose is fine with either. Mia to confirm with her lender.",
  author: { name: "Sam Evans", initials: "SE", viaFirmPilot: true },
};
```

### Tiles

Pinned, with comments, written by Firm Pilot for Sam; a plain note with an attachment.

```tsx
<div className="grid w-xl grid-cols-2 gap-3">
  <NoteTile {...call} pinned comments={3} />
  <NoteTile
    kind="note"
    date="18 Nov"
    title="Finance pre-approval received"
    excerpt="Rose sent the pre-approval letter from her broker, valid to 15 Jan. Saved under Documents."
    author={{ name: "Mia Gold", initials: "MG" }}
    attachments={1}
  />
</div>
```

### Where it belongs

On an opportunity, a note kept on the contact shows the contact; on a contact, each note shows its matter.

```tsx
<div className="grid w-xl grid-cols-2 gap-3">
  <NoteTile
    kind="note"
    date="2 Nov"
    title="Prefers email, not calls"
    excerpt="Rose asked us to email rather than call during work hours."
    author={{ name: "Mia Gold", initials: "MG" }}
    context={{ type: "contact", label: "Rose Citizen" }}
  />
  <NoteTile
    {...call}
    context={{ type: "matter", label: "14 Hill St purchase" }}
  />
</div>
```

### Selected and highlighted

Selected is the note open beside the grid. The highlight shows only when someone is taken to the note, from a notification, a link or search, never for one they just wrote.

```tsx
<div className="grid w-xl grid-cols-2 gap-3">
  <NoteTile {...call} selected />
  <NoteTile {...call} highlighted />
</div>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `kind` (required) | `NoteKind` |  | What the note records. Sets the 12 px icon and the word before the date. |
| `date` (required) | `string` |  | When it was written, already formatted, like "21 Nov" or "Just now". |
| `title` (required) | `string` |  | The note's title. One line; it clips with an ellipsis. |
| `excerpt` (required) | `string` |  | The start of the note. Three muted lines. |
| `author` (required) | `NoteAuthor` |  | Who wrote it. With `viaFirmPilot`, a small Firm Pilot mark follows their name. |
| `pinned` | `boolean` | `false` | Shows the navy pin. Pinned notes come first in a NoteGrid. |
| `context` | `NoteContext` |  | Where the note belongs, only when that isn't this page: its matter on a contact, its contact on an opportunity. |
| `comments` | `number` | `0` | How many comments. Shown only above 0. |
| `attachments` | `number` | `0` | How many attachments. Shown only above 0. |
| `selected` | `boolean` | `false` | The note open beside the grid: a focus-blue border. Sets aria-pressed. |
| `highlighted` | `boolean` | `false` | Someone was taken to this note, from a notification, a link or search. Never set it for a note they just wrote. |
| `onOpen` | `() => void` |  | Opens the note. |
| `ref` | `Ref<HTMLButtonElement>` |  | For useHighlight, which scrolls the tile into view. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
