Merge Resolver
Per-field conflict resolution for structured records with diff highlights, custom overrides, and batch actions.
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
"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.
Controlled state and custom overrides
Controlled conflict resolutions with pre-selected custom overrides and external reset controls.
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 | Type | Default |
|---|---|---|
fieldsRequiredMergeField[]List of fields with name, optional label, ours value, theirs value, and optional base value. | MergeField[] | |
valueMergeResolutionsControlled resolutions. | MergeResolutions | |
defaultValueMergeResolutionsDefault{}Initial value when uncontrolled. | MergeResolutions | {} |
onValueChange(resolutions: MergeResolutions) => voidCalled when any field's resolution choice or custom value changes. | (resolutions: MergeResolutions) => void | |
onResolve(merged: MergedRecord) => voidCalled when the save resolutions button is clicked with the fully resolved record. | (merged: MergedRecord) => void | |
oursLabelstringDefault"Ours (Local)"Label for the local/ours option. | string | "Ours (Local)" |
theirsLabelstringDefault"Theirs (Remote)"Label for the remote/theirs option. | string | "Theirs (Remote)" |
customLabelstringDefault"Custom"Label for the custom override option. | string | "Custom" |
resolveLabelstringDefault"Save resolutions"Text on the submit/resolve button. | string | "Save resolutions" |
acceptAllOursLabelstringDefault"Accept all ours"Text on the batch accept ours button. | string | "Accept all ours" |
acceptAllTheirsLabelstringDefault"Accept all theirs"Text on the batch accept theirs button. | string | "Accept all theirs" |
disabledbooleanDefaultfalseDisables all radio inputs, custom text inputs, and action buttons. | boolean | false |
Other props go to the <div>.
MergeField
A single record field undergoing conflict evaluation.
| Prop | Type | Default |
|---|---|---|
nameRequiredstringUnique field identifier in the record. | string | |
oursRequiredstringLocal version of the field value. | string | |
theirsRequiredstringRemote or conflicting version of the field value. | string | |
labelstringHuman-readable label shown in the UI header. | string | |
basestringCommon ancestor value for 3-way context display if available. | string |
MergeFieldResolution
The resolution choice and optional custom value for one field.
| Prop | Type | Default |
|---|---|---|
choiceRequired"ours" | "theirs" | "custom"Which option was chosen for this field. | "ours" | "theirs" | "custom" | |
customValuestringCustom value when choice is 'custom'. | string |