# Mail Route List

> The aliases and forwards of a domain: each address with where it delivers to, its kind and whether it is active.

Component · Data · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/MailRouteList/)

The aliases and forwards of a domain: each address with where it delivers to, its kind and whether it is active. "Add address" opens a small form (the local part with the domain, the targets as address chips, alias or forward); deleting asks first.

## Example

```tsx
import * as React from "react";
import { MailRouteList } from "@twentyfirstmedia/pro";
import type { MailRoute } from "@twentyfirstmedia/pro";

export default function Preview() {
  const [routes, setRoutes] = React.useState<MailRoute[]>([
    { address: "hello@example.com", targets: ["mara@example.com", "jonah@example.com"] },
    { address: "jobs@example.com", targets: ["ava@example.com"] },
    {
      address: "invoices@example.com",
      targets: ["bookkeeping@accounts.example.org"],
      kind: "forward",
      note: "Keeps a copy",
    },
    { address: "press@example.com", targets: ["mara@example.com"], active: false },
  ]);
  return (
    <div className="tf-panel" style={{ gap: 16 }}>
      <MailRouteList
        domain="example.com"
        routes={routes}
        suggestions={[
          { address: "mara@example.com", name: "Mara Ellis" },
          { address: "jonah@example.com", name: "Jonah Petit" },
          { address: "ava@example.com", name: "Ava Brandt" },
        ]}
        onAdd={(r) => setRoutes((l) => l.concat([r]))}
        onDelete={(a) => setRoutes((l) => l.filter((r) => r.address !== a))}
      />
    </div>
  );
}
```

## Props

### MailRouteList

| Prop | Type | Notes |
| --- | --- | --- |
| `routes` | `MailRoute[]` | Required |
| `domain?` | `string` | The domain new addresses belong to ("example.com"). |
| `onAdd?` | `(route: { address: string; targets: string[]; kind: "alias" \| "forward" }) => void` | Shows "Add address" with a small form. |
| `onDelete?` | `(address: string) => void` | Delete (after a confirmation). |
| `suggestions?` | `MailRecipient[]` | Mailboxes suggested as targets. |
| `busy?` | `boolean` |  |
| `label?` | `string` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### RecipientInput

| Prop | Type | Notes |
| --- | --- | --- |
| `label` | `string` | Required |
| `hideLabel?` | `boolean` |  |
| `id?` | `string` |  |
| `value?` | `MailRecipient[]` | The addresses (controlled) / initially / on change. |
| `defaultValue?` | `MailRecipient[]` |  |
| `onChange?` | `(value: MailRecipient[]) => void` |  |
| `suggestions?` | `MailRecipient[]` | Known addresses, filtered while typing. |
| `suggest?` | `(typed: string) => MailRecipient[] \| Promise<MailRecipient[]>` | Or ask your server while typing (debounced). |
| `validate?` | `(address: string) => boolean` | Your own address check (default: a plain e-mail pattern). |
| `placeholder?` | `string` |  |
| `hint?` | `string` |  |
| `error?` | `string` |  |
| `disabled?` | `boolean` |  |
| `autoFocus?` | `boolean` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
