# Merge Records

> Two or more duplicates side by side: for every field that differs, pick which value to keep, then merge.

Component · CRM · Halo kit · [Live page](https://ui.twentyfirst.media/halo/components/MergeRecords/)

Two or more duplicates side by side: for every field that differs, pick which value to keep, then
merge.

- Rows that differ are marked; the kept value is highlighted. `value` and `onChange` hold the
  choice per field, `onMerge` gets it.

## Example

```tsx
import { MergeRecords, Panel } from "@twentyfirstmedia/halo";

export default function Preview() {
  return (
    <Panel
      title="Merge duplicates"
      subtitle="Pick what to keep per field"
      style={{ maxWidth: 760 }}
    >
      <MergeRecords
        records={[
          {
            id: "a",
            title: "Lena Hartmann",
            subtitle: "Created Mar 2023 · 48 activities",
            values: {
              email: "lena@nordhafen.de",
              phone: "+49 40 2287 1190",
              company: "Nordhafen Outdoor",
              title: "Head of Operations",
              city: "Hamburg",
            },
          },
          {
            id: "b",
            title: "L. Hartmann",
            subtitle: "Imported Oct 2026 · 2 activities",
            values: {
              email: "l.hartmann@nordhafen.de",
              phone: "+49 40 2287 1190",
              company: "Nordhafen Outdoor GmbH",
              title: "",
              city: "Hamburg",
            },
          },
        ]}
        fields={[
          { id: "email", label: "Email" },
          { id: "phone", label: "Phone" },
          { id: "company", label: "Company" },
          { id: "title", label: "Job title" },
          { id: "city", label: "City" },
        ]}
        onMerge={() => {}}
      />
    </Panel>
  );
}
```

## Props

### MergeRecords

| Prop | Type | Notes |
| --- | --- | --- |
| `records` | `{ id: string; title: string; subtitle?: string; values: Record<string, ReactNode> }[]` | Two (or more) records that are the same thing. |
| `fields` | `{ id: string; label: string }[]` | Required |
| `value?` | `Record<string, string>` | Which record's value to keep per field (default: the first record's, or the first that has one). |
| `onChange?` | `(value: Record<string, string>) => void` |  |
| `onMerge?` | `(value: Record<string, string>) => void` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Panel

| Prop | Type | Notes |
| --- | --- | --- |
| `side?` | `boolean` |  |
| `title?` | `string` |  |
| `subtitle?` | `string` |  |
| `action?` | `ReactNode` |  |
| `children?` | `ReactNode` |  |
| `surface?` | `Surface` | `"glass"`: translucent glass over what is behind (maps, 3D, video, photos); `"solid"` opts out inside a glass `UIProvider`. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
