# File diff

One file's change: its path, the lines it adds and removes in two gutters, and its place in the turn, folded.

Live variants: https://design.arcadia.is/components/file-diff

```tsx
import { FileDiff, DiffCounts, DiffBar } from "@arcadia/ui";
```

```tsx
import { FileDiff } from "@arcadia/ui";

<FileDiff path="src/cache.ts" lines={LINES} defaultOpen />
```

## Accessibility

The header is a button named by the path and its counts, with its expanded state told. Each line is read with "Added" or "Removed" before its code when it is not context, and the line numbers and markers are hidden. A streaming diff is busy until it settles. The body is one tab stop when a long line or a bounded body overflows, so the keys scroll it.

## API reference

### FileDiff

- `path` (`string`, required): The file's path, as git prints it.
- `oldPath` (`string`): Its path before a rename.
- `lines` (`readonly FileDiffLine[]`, required): Its lines, in file order. May grow while `status` is "streaming".
- `status` (`"streaming" | "complete"`, default `"complete"`): "streaming": the header is live and the region busy.
- `maxLines` (`number`): The lines it shows before it scrolls; its end stays in view while the change is applied. Without it the diff is as tall as its lines.
- `open` (`boolean`): Controlled open state.
- `defaultOpen` (`boolean`, default `false`): Open when it arrives.
- `onOpenChange` (`(open: boolean, details: OpenChangeDetails) => void`): Called when the header toggles it.
- `rootStyle` (`RootStyle<FileDiffKnobs>`): Typed StyleX override: where the diff sits and its `--file-diff-*` knobs.
