File Tree
The files an agent changed, as a tree with what happened to each one and how many lines moved.
NewInstallation
Copy and paste the following code into your project.
Update the import paths to match your project structure.
Anatomy
Pass a flat list of paths and the folders are built for you. A folder with a single folder inside folds into one row (
src/checkout), the way code review tools show it, and folders come before files.Each file shows its additions and deletions and a letter for what happened: Added, Modified, Deleted or Renamed. The header adds them all up, so the size of the change is clear before anyone opens a file.
It is built on Tree, so it brings the same keyboard support.
Keyboard
โ and โ move between rows, โ opens a folder or moves into it, โ closes it or goes back to the parent, Home and End jump to the ends, and Enter picks a file.Accessibility
- It is a
treenamed after the title, with each file as atreeitem. - Each file is read as "total.ts, Modified, 12 additions, 3 deletions"; the letter and the plus and minus counts are hidden, since they only make sense visually.
- A deleted file keeps its name struck through and announces "Deleted".
API Reference
FileTree
| Prop | Type | Default | Description |
|---|---|---|---|
files | FileChange[] | - | The changed files |
title | ReactNode | 'Files changed' | Text of the header |
label | string | the title | Accessible name of the tree |
selected | string | - | Controlled selected path |
defaultSelected | string | - | Selected path when uncontrolled |
onFileSelect | (path: string) => void | - | Called when a file is picked |
expanded | string[] | - | Controlled open folders |
defaultExpanded | string[] | every folder | Open folders when uncontrolled |
onExpandedChange | (expanded: string[]) => void | - | Called when a folder opens or closes |
statusLabels | Partial<Record<Status, string>> | - | Screen reader labels for each status |
changesLabel | (additions: number, deletions: number) => string | "12 additions, 3 deletions" | Changes read by screen readers |
className | string | - | Additional CSS classes |
FileChange is { path: string; status?: 'added' | 'modified' | 'deleted' | 'renamed'; additions?: number; deletions?: number }.Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.