Layout & display
DiffView
What changed between two versions, one row per field. The kit draws the list, and working out what changed stays with the page.
Basic
Pass one entry per field that changed. Each row names its field and says what happened to it in a word, Added, Removed, Changed or Moved, so the kind of change never rests on color. A changed field shows its old value marked Removed above its new value marked Added. A move carries a sentence of your own, such as where the field went. A value emptied by the change reads "Empty".
- Title ChangedRemovedAdded
Spring sale
Spring sale, ends Friday
- Subtitle Added
Every plan, 20% off
- Banner image Removed
hero-winter.png
- Pricing section Moved
From position 4 to 2
- Footer note ChangedRemovedAdded
Prices exclude tax.
Empty
Long values
A value longer than 400 characters shows its first 400 and a Show all button. The cut falls between two characters a reader sees as whole, so an emoji or an accented letter is never split. Each button names its value to a screen reader, as in "Show all of Body, added", so a list of them can be told apart. Every value folds again when the page passes other changes.
- Body ChangedRemovedAdded
Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% of
Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% off until Friday, and the discount stays for a full year. Every plan is 20% of
Direction and sameness
Every label and value takes its direction from its own text, so an Arabic or Hebrew value reads right to left inside a left-to-right page, and the other way round. With no changes the list says "These versions are the same."
API
| Prop | Type | Default | Description |
|---|---|---|---|
changes required | DiffChange[] | no default | One entry per field that changed, in the order to list them. |
class | string | no default | Extra classes on the wrapper. |
DiffChange
A union on kind: an added, removed or moved field carries value, and a
changed one carries before and after.
| Prop | Type | Default | Description |
|---|---|---|---|
kind required | 'added' | 'removed' | 'changed' | 'moved' | no default | What happened to the field. It sets the word on the row. |
label required | string | no default | The field's name, shown first on the row. |
value | string | no default | The value added or removed. For a move, where it went in your words, such as "From position 2 to 4". |
before | string | no default | The old value of a changed field. |
after | string | no default | The new value of a changed field. |