Merge Resolver

Per-field conflict resolution for structured records with diff highlights, custom overrides, and batch actions.

@drift-ui/merge-resolverRegistry JSONOpen in v0
2 unresolved conflicts remaining2 remaining
Document Title(Base: Product Roadmap)
Conflict
AuthorNo conflict
Alex Rivera
Summary(Base: Initial draft roadmap.)
Conflict
On this page

Installation

The CLI also installs the npm packages and registry items it builds on, and reads the style in your components.json to pick the Base UI or Radix build.

Usage

merge-resolver-usage.tsx
"use client"

import { MergeResolver } from "@/components/ui/merge-resolver"

const fields = [
  { name: "title", label: "Title", ours: "Draft Roadmap", theirs: "Final Roadmap" },
  { name: "status", label: "Status", ours: "published", theirs: "published" },
  { name: "description", label: "Description", ours: "Sprint dates added", theirs: "Milestones updated" },
]

export function DocumentMerge() {
  return (
    <MergeResolver
      fields={fields}
      onResolve={(merged) => console.log("Merged record:", merged)}
    />
  )
}

Examples

Basic conflict resolution

Per-field merge resolver with diff highlights, remaining conflict announcements, and bulk accept buttons.

2 unresolved conflicts remaining2 remaining
Display Name
Conflict
Role
Conflict
StatusNo conflict
Active

Controlled state and custom overrides

Controlled conflict resolutions with pre-selected custom overrides and external reset controls.

1 unresolved conflict remaining1 remaining
API Endpoint
Resolved
Timeout (seconds)
Conflict

API reference

MergeResolver

Resolves conflicts between two versions of a structured record on a field-by-field basis. Displays word-level diff highlights distinguishing changes using semantic ins/del tags, offers ours/theirs/custom choices, supports batch acceptance, and announces remaining conflicts to screen readers.

Prop
fieldsRequiredMergeField[]List of fields with name, optional label, ours value, theirs value, and optional base value.
valueMergeResolutionsControlled resolutions.
defaultValueMergeResolutionsDefault{}Initial value when uncontrolled.
onValueChange(resolutions: MergeResolutions) => voidCalled when any field's resolution choice or custom value changes.
onResolve(merged: MergedRecord) => voidCalled when the save resolutions button is clicked with the fully resolved record.
oursLabelstringDefault"Ours (Local)"Label for the local/ours option.
theirsLabelstringDefault"Theirs (Remote)"Label for the remote/theirs option.
customLabelstringDefault"Custom"Label for the custom override option.
resolveLabelstringDefault"Save resolutions"Text on the submit/resolve button.
acceptAllOursLabelstringDefault"Accept all ours"Text on the batch accept ours button.
acceptAllTheirsLabelstringDefault"Accept all theirs"Text on the batch accept theirs button.
disabledbooleanDefaultfalseDisables all radio inputs, custom text inputs, and action buttons.

Other props go to the <div>.

MergeField

A single record field undergoing conflict evaluation.

Prop
nameRequiredstringUnique field identifier in the record.
oursRequiredstringLocal version of the field value.
theirsRequiredstringRemote or conflicting version of the field value.
labelstringHuman-readable label shown in the UI header.
basestringCommon ancestor value for 3-way context display if available.

MergeFieldResolution

The resolution choice and optional custom value for one field.

Prop
choiceRequired"ours" | "theirs" | "custom"Which option was chosen for this field.
customValuestringCustom value when choice is 'custom'.

Source

components/ui/merge-resolver.tsx