File Diff

A syntax-highlighted file change disclosure with progressive rows, line numbers, live change counts, smooth following, and completion collapse.

Preview

File changes

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/file-diff

API Reference

file
ReactNode
lines
FileDiffLine[]
status?
"complete" | "streaming"
streaming
open?
boolean
defaultOpen?
boolean
true
onOpenChange?
((open: boolean) => void)
collapseOnComplete?
boolean
true
maxHeight?
number
220
language?
"text" | "bash" | "diff" | "json" | "tsx" | "typescript"
typescript
copyText?
string
onCopy?
(() => void | Promise<void>)
className?
string

Composition

Place the patch inside the tool output that produced the file change.

ToolResult
└── ToolResultOutput
    └── FileDiff

Note: Code Block provides the shared syntax presentation for source lines. Tool Result summarizes the command or edit that produced the patch. Agent Activity records the file edit among surrounding agent events.

How it works

A file diff explains a proposed or completed edit. It should preserve the relationship between old and new lines while making the scale and status of the change visible at a glance.

Updated