Pro
File diff
A line-by-line comparison of two versions of a file.
pnpm dlx shadcn@latest add @caliper/file-diffWhen to use
Use it for
- Showing what an agent or a commit changed in a file.
- Reviewing edits before they are applied.
Skip it when
- The comparison is of rich text or images.
- Files are very large; page or collapse them first.
Installation
pnpm dlx shadcn@latest add @caliper/file-diff
Adds its 6 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
Import it from your copy of the source. The example behind the preview comes with the source. It is built from FileDiff and diffLines.
import { FileDiff, diffLines } from "@/components/ui/file-diff"
The worked example comes with Pro
The 89-line example behind the preview opens here, ready to copy.
- 626 Pro parts, blocks and page templates, all with source
- $149 once, with lifetime updates. No renewal
- A full refund within 14 days if it is not for you
API reference
FileDiff
component
diffLines
component
No props of its own; it accepts the native props of its root element.
Accessibility
It exposes group and region semantics, with aria-label, aria-expanded, aria-controls, aria-hidden and aria-pressed kept in step with state.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.