Components

FieldDiff

Side-by-side comparison of original and corrected field values with change highlighting.

Category: Data Display / Standalone

Import

import { FieldDiff, type FieldDiffProps } from "@hareru/ui"

Exports

NameTypeDescription
FieldDiffComponentField diff comparison
FieldDiffPropsTypeProps interface

Key Props

PropTypeDefaultDescription
originalRecord<string, unknown>Original field values (required)
correctedRecord<string, unknown>Corrected field values (required)
changedFieldsstring[]List of field keys that were changed (required)
labelsRecord<string, string>Human-readable labels for field keys

States

StateTypeValuesDefaultCSS Reflection
modeenuminline | side-by-sideinline

Usage

import { FieldDiff } from "@hareru/ui"

<FieldDiff
  original={{ name: "John", email: "john@old.com", role: "user" }}
  corrected={{ name: "John", email: "john@new.com", role: "admin" }}
  changedFields={["email", "role"]}
  labels={{ name: "Name", email: "Email", role: "Role" }}
/>

Notes

  • All keys from both original and corrected are displayed. Changed fields are highlighted with hui-field-diff__row--changed modifier.
  • Changed values show original (with --removed styling) → arrow → corrected (with --added styling).
  • If labels is not provided, the raw field key is used as the display label.
  • Values are converted to strings via String() for display.

On this page