# File Diff

> Shiki-highlighted added and removed lines with live change counts.

Registry name: `file-diff`. HTML docs: https://ui.anuragroy.dev/component/file-diff.

## Install

```bash
npx shadcn@latest add https://ui.anuragroy.dev/r/file-diff.json
```

If the website is down: `npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/file-diff.json`.

Registry JSON: https://ui.anuragroy.dev/r/file-diff.json (GitHub: https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/file-diff.json).

## Import

Import paths follow the consumer `components.json` aliases. After a default install:

```tsx
import {
  FileDiff,
  FileDiffBody,
  FileDiffFilename,
  FileDiffHeader,
  FileDiffLine,
  FileDiffStats
} from "@/components/ui/file-diff"
```

## Usage

```tsx
import {
  FileDiff,
  FileDiffBody,
  FileDiffFilename,
  FileDiffHeader,
  FileDiffLine,
  FileDiffStats,
} from "@/components/ui/file-diff"

export function Example() {
  return (
    <FileDiff lang="tsx">
      <FileDiffHeader>
        <FileDiffFilename>src/app-sidebar.tsx</FileDiffFilename>
        <FileDiffStats additions={1} deletions={1} />
      </FileDiffHeader>
      <FileDiffBody>
        <FileDiffLine type="removed" number={13}>
          {'  return <nav className="w-72" />'}
        </FileDiffLine>
        <FileDiffLine type="added" number={13}>
          {'  return <nav className="w-60" />'}
        </FileDiffLine>
      </FileDiffBody>
    </FileDiff>
  )
}
```

## API

### FileDiff

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `lang` | string | — |  |
| `filename` | string | — | Used to infer `lang` when it is omitted. |

### FileDiffLine

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` | "context" \| "added" \| "removed" | — |  |
| `number` | number | — |  |

### FileDiffStats

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `additions` | number | — |  |
| `deletions` | number | — |  |

## See also

- [HTML page](https://ui.anuragroy.dev/component/file-diff): Preview and the same docs in the site chrome.
- [Registry item](https://ui.anuragroy.dev/r/file-diff.json): Source files and dependencies.
- [Catalog](https://ui.anuragroy.dev/component): All components.
- [llms.txt](https://ui.anuragroy.dev/llms.txt): Agent index for this library.
