# PR Review

> An animated pull request review for React and shadcn, with a diff, line comments and hold to approve.

A pull request review: a highlighted diff with line comments and an Approve button you hold while it fills. Switching unified and split glides every line to its new place, and comment threads open under their line on Auto Height.

- Tier: Eased Pro
- Interaction: Press
- Page: https://eased.dev/components/pr-review
- Installs: motion

## Install

PR Review ships with Eased Pro (https://eased.dev/#pricing). Members add the `@eased-pro` registry with their token (https://eased.dev/account), then run:

```bash
npx shadcn add @eased-pro/pr-review
```

A pull request review of one file: a highlighted diff (code-core's Shiki), line comments and a held Approve, with jsdiff hunks from doc-core.

## When to use

- A code review, an AI agent's proposed change, or a config change that needs sign-off with discussion on specific lines.
- When unified and side-by-side views both matter to your readers.

## When not to use

- An agent asking to apply a change with no discussion: use [Approval Card](/components/approval-card).
- Prose or contract changes: a word-level redline reads better than lines.

## Usage

```tsx example.tsx
import { lineHunks } from "@/components/eased/_primitives/doc-core/doc-core";
import { PRReview } from "@/components/eased/pr-review/pr-review";

const hunks = lineHunks(before, after); // outside render: jsdiff reads the clock

<PRReview
  path="src/app/billing/invoice-row.tsx"
  lang="tsx"
  before={before}
  after={after}
  hunks={hunks}
  comments={comments}
  onComment={(anchor, body) => save(anchor, body)}
  approved={approved}
  onApprove={() => approve()}
/>;
```

## API reference

### PRReview

| Prop | Type | Default | Description |
|---|---|---|---|
| `path` | `string` | | The file path above the diff. |
| `before` / `after` | `string` | | Both versions, for highlighting. |
| `hunks` | `DiffHunk[]` | | The change, e.g. doc-core `lineHunks(before, after)`. |
| `lang` | `string` | | Shiki grammar, e.g. `"tsx"`. |
| `comments` | `ReviewComment[]` | `[]` | `{ id, anchor, author, body, when? }`. `anchor` is `n42` (new line 42) or `o17` (old line 17). |
| `onComment` | `(anchor, body) => void` | | Enables commenting. |
| `mode` / `defaultMode` / `onModeChange` | `"unified" \| "split"` | `"unified"` | The diff layout. Under 24rem the toggle hides and the diff stays unified. |
| `onApprove` / `approved` | `() => void` / `boolean` | | Shows the hold-to-approve button. |
| `holdMs` | `number` | `900` | How long Approve must be held. |
| `header` | `ReactNode` | | Above the file bar: the PR's meta. |
| `className` | `string` | `""` | Appended to the root. |

## Keyboard

| Key | Action |
|---|---|
| `Tab` | Layout toggle, the diff, each line number (opens a comment box), then Approve. |
| `⌘` / `Ctrl` + `Enter` | Posts the comment. |
| `Esc` | Cancels the comment box. |
| Hold `Space` / `Enter` | Approves once the fill completes. |

## Accessibility

- The diff is a named, focusable region; added and removed lines are labelled; line-number buttons are named "Comment on line 11".
- The comment count is a polite live region. Approve is named "Approve: press and hold", then "Approved".

## Motion

Switching layouts is a FLIP: every line keeps a shared layout id and glides to its new place on the smooth spring (position only, so text never stretches); context lines' new-side copies fade in. Comment boxes open under their line on Auto Height. Approve fills with brand left to right in linear time while held and drains on the smooth spring if let go early. Reduced motion: lines jump, Auto Height snaps.

## Notes for AI

Compute `hunks` once outside render and keep comments in your own store keyed by anchor. One PRReview shows one file; render several for a multi-file PR.

Don't re-highlight the code or wrap rows in your own motion: the component does both, and extra layout animations will fight its FLIP.

## Related

- [Approval Card](/components/approval-card): approve an agent's change without discussion.
- [Code Block](/components/code-block): highlighted code with no diff.
