Git Tree
A repository's files at a commit on UI SDK's Tree: folders first with lucide icons, changed files marked added, modified, deleted or renamed in their tone, folders that hold a change marked too. Virtualized for 100,000 files; agents open and expand by path.
Example
src, Has changes
billing, Has changes
proration.ts, Modified
plans.ts
legacy-rates.ts, Deleted
invoice, Has changes
pdf.ts, Renamed, from src/invoice/print.ts
fonts.ts
routes.ts, Added
index.ts
docs
public
package.json
README.md
tsconfig.json
src/billing/proration.ts
git-tree-demo.tsxCopy code
Installation
Copy code
npm packages
lucide-reactUsage
ImportCopy code
Use it for a repository's files at a commit, with what changed marked.
API reference
GitTree
| Prop | Type | Default |
|---|---|---|
aria-labelrequired | string | – |
filesrequiredA path ending in `/` is an empty folder. | readonly (string | GitTreeFile)[] | – |
expandedBy default the folders that hold a change start open. | readonly string[] | – |
defaultExpanded | readonly string[] | – |
onExpandedChange | GitTreeOptions["onExpandedChange"] | – |
currentThe file shown elsewhere, like the one a diff is open on. | string | null | – |
onOpenFile | GitTreeOptions["onOpenFile"] | – |
labels | Partial<GitTreeLabels> | – |
estimateSizeA row's height in px before it is measured. @defaultValue 32 | number | 32 |
findableFind in page reaches rows scrolled out of view, once the page is idle after its first paint. Off by default: on 100,000 files it costs up to a frame on some held-arrow presses (p95 about 16 ms against 10 ms). | boolean | false |
Also takes <div> attributes and render except children, onSelect, defaultValue.
Other exports
gitTreeLabelsgitTreegitStatusTonesindexGitFilesparentsOftype GitTreeLabelstype GitTreePropstype GitTreeChangeReasontype GitTreeLookuptype GitTreeOptionstype GitFileStatustype GitTreeFiletype GitTreeIndexAccessibility
- UI SDK's tree pattern: arrows, typeahead, Left and Right to fold, Enter to open a file.
- A changed file's status is part of its name, not only its colour or letter.
Agent actions
Agents open, expand and collapse by path; the files are listed for query().
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.