# Application Developer Tool: Diff Viewer

A code review diff with a compare header, branch chips, change totals, per file cards, and a unified diff tinting added and removed lines.

- Page: https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/diff-viewer
- Collection: [Application](https://www.shadcn-ui-blocks.com/blocks/application-pro), Standard tier
- Group: [Developer Tools](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools)
- Created: 2026-07-10
- Preview image: https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/diff-viewer.png

## Install

```bash
npx shadcn@latest add @shadcn-ui-blocks/application-pro-developer-tools-diff-viewer
```

Needs an API key from a Pro or Team plan: add `@shadcn-ui-blocks` to the registries in components.json with the key as an `Authorization: Bearer` header. Setup: https://www.shadcn-ui-blocks.com/docs/shadcn-cli. The MCP server installs it without the setup: https://www.shadcn-ui-blocks.com/docs/mcp.

## Depends on

- npm packages: class-variance-authority, lucide-react, radix-ui
- shadcn/ui components: badge, button
- Installs to: `@/components/blocks/application-pro/developer-tools/diff-viewer`

## About this block

Diff Viewer is the code review surface, comparing main
with feature/rate-limit-retry. The compare header carries
the two branch chips, a +9 -3 change total in tabular-nums,
and Request changes and Approve buttons. The expanded file
card for lib/api/rate-limit.ts shows a modified Badge, its
own +5 -2 count, and a unified diff with dual line number
gutters, an @@ hunk header, and added lines tinted with
primary and removed lines with destructive. The test file
sits collapsed below with a chevron and its own +4 -1 count.

Diff lines are one typed const array keyed by kind, context,
add, or remove. A lineStyles Record maps each kind to a row
tint, a prefix colour, and a sign so the diff reads the same
in light and dark without any hard-coded colour values.

## When to use

Reach for this block on a code review or pull request page,
wired to your diff API. Render the file cards from your patch
data, collapse files once an engineer marks them viewed, and
reopen them if the file changes again before merge.

A natural flow around it on an Application Pro page:

**Before**

- [App shell](https://www.shadcn-ui-blocks.com/blocks/application-pro/app-shells)
- [Build status list](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools)

**After**

- [Comments and annotations](https://www.shadcn-ui-blocks.com/blocks/application-pro/comments-annotations)
- [Notifications](https://www.shadcn-ui-blocks.com/blocks/application-pro/notifications)

## What you can display

One strong use is the pull request diff review. Other diff
surfaces:

- **Split view.** Render old and new side by side instead of
  unified for wide screens and heavy rewrites.
- **Suggested change.** Add a comment thread under a hunk with
  an accept button that commits the suggestion.
- **Conflict resolver.** Mark both sides of a merge conflict
  and let the reviewer pick a hunk to keep.

> Tip: keep viewed files collapsed but reopen them on new
> commits so a stale approval never hides fresh changes.

## More in Application Developer Tools

- [Api Console](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/api-console)
- [Build Status List](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/build-status-list)
- [Cron Jobs Monitor](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/cron-jobs-monitor)
- [Dependency Audit](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/dependency-audit)
- [Deploy Panel](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/deploy-panel)
- [Env Vars Manager](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/env-vars-manager)
- [Error Inbox](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/error-inbox)
- [Feature Flags Panel](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/feature-flags-panel)
- [Log Viewer](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/log-viewer)
- [Migrations Panel](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/migrations-panel)
- [SDK Quickstart](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/sdk-quickstart)
- [Secrets Rotation Card](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/secrets-rotation-card)
- [SQL Query Editor](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/sql-query-editor)
- [Terminal Panel](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/terminal-panel)
- [Trace Waterfall](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/trace-waterfall)
- [Webhook Logs Table](https://www.shadcn-ui-blocks.com/blocks/application-pro/developer-tools/webhook-logs-table)
