Ballmac UI home

Prompt Diff

New

Two versions of a prompt compared word by word: removed words struck through and added words underlined so colour is never the only cue, a count of each, {{variables}} marked, side by side or inline, and an optional Restore button.

v1.0.0Updated Oct 24, 2026Ships with a test
What changed

+17 words·−1 words

v12 · 3 Oct

You are a support assistant for {{company}}. Answer questions about orders and refunds. Be friendly and keep answers [removed: short]. If you do not know the answer, say so. Never promise a refund.

v13 · today

You are a support assistant for {{company}}. Answer questions about orders[added: ,] [added: shipping ]and refunds. Be friendly and keep answers [added: under {{max_words}} words]. If you do not know the answer, say so[added: and offer to pass the conversation to a person]. Never promise a refund[added: before checking the policy].

Installation

$ pnpm dlx shadcn@latest add @ballmac/prompt-diff

Usage

import { PromptDiff, diffWords } from "@/components/ballmac/prompt-diff"

The full example is in the Code tab above.

Examples

Inline, with restore

+8 words·−7 words

v7 → v8

Summarise the ticket in [removed: two][added: one] [removed: sentences][added: sentence]. Include the [removed: customer's][added: order] [removed: name][added: number.] [removed: and][added: Leave] [added: out ]the [removed: order][added: customer's] [removed: number][added: name].

API reference

PropTypeDefault
before*

The earlier version.

string—
after*

The later version.

string—
beforeLabel

Name of the earlier version, for example "v12, 3 Oct".

string—
afterLabel

Name of the later version.

string—
mode

Layout: side by side, or one text with changes marked inline.

"split" | "unified"—
onRestore

Called when the person asks to go back to the earlier version. Adds the button.

() => void—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Screen readersChanges are read as '[removed: old words]' and '[added: new words]'; the counts are a polite live region
ColourRemoved words are struck through and added words underlined, so the difference never depends on colour
Tab, Enter / SpaceThe view switch is two toggle buttons (aria-pressed); Restore is a real button

Use with AI

before and after are the two texts; beforeLabel / afterLabel name them; mode is 'split' (default) or 'unified'; onRestore adds a 'Restore <before label>' button. Exports diffWords(before, after) returning [{ type: 'same' | 'add' | 'del', text }]. Compares words and keeps spacing; inputs over 200,000 word pairs are shown as fully replaced. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Prompt Diff (@ballmac/prompt-diff) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Reviewing what changed between two prompt versions before shipping or rolling back
  • Any short text where the exact words changed matter

Not for

  • Code or files; use diff-viewer
  • Comparing model outputs side by side; use parallel-attempts

Registry JSON: https://ui.ballmac.com/r/prompt-diff.json

Credits

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.