App components / Tree views
Tree view
Nested files and folders, one Tree item per row: an open or closed folder, or a file, with a count or change in mono on the right. File tree puts it on the tray and card, with depth guides and a mono footer count.
MembersReact · Vue · HTMLFigma: Tree views
Code
The component itself, ready to drop into your project. Switch between React, Vue and plain HTML; every version uses the same Tailwind classes on Ochre's tokens.
northwind-web
app4
layout.tsx
page.tsxM
settings3
page.tsx+12
members.tsxM
billing.tsx
globals.css
components3
lib2
README.md
package.jsonM
app/settings/members
Installation
Examples
Tree item
Each kind in its default, hover and selected look.
Default
settings4
invoices12
members.tsxM
Hover
settings4
invoices12
members.tsxM
Selected
settings4
invoices12
members.tsxM
Sizes
S to XXL.
Q3 roadmap3
Brief.md
Research notes.md+2
Launch plan.md
NW-118 audit1
Motion
Built on Ochre's ease-out curves. With reduced motion switched on, everything still works, it just doesn't move.
01The chevron turns a quarter as its folder opens or closes.
02Rows that appear when a folder opens fade in one after another, 40 ms apart; closing removes them at once.
03Rows shade on hover.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | TreeNode[] | – | { id, label, meta?, icon?, disabled?, children? }. A node with children is a folder. |
| label | string | – | The tree's accessible name. File tree defaults it to Files. |
| size | "s" | "m" | "l" | "xl" | "xxl" | "s" | Row height 32 to 64, text 13 to 20. Indent and guides grow with it. |
| expanded / defaultExpanded / onExpandedChange | string[] | – | Open folders, controlled or not. |
| selected / defaultSelected / onSelect | string | null | – | The selected row: shaded, with its icon in orange, and aria-selected. |
| icons | boolean | true | Folder and file icons. Turn off for plain nested lists. |
| guides | boolean | true | Hairlines that run down from each open folder. |
| FileTree title / action / footer | ReactNode | – | The tray strip above the card, and the mono count below it. footer null hides it. |
| TreeItem kind | "folder-open" | "folder-closed" | "file" | "file" | One row on its own, for your own trees. Also takes label, meta, depth, selected, size and icon. |
| useTreeNav / flattenTree | hooks | – | The keyboard model the Outline and Checkbox tree share: arrows, Home, End, Enter, * and typeahead. |
Usage
Use it for
- A repository, a project's documents or any folder structure people open and close.
- S in side panels and on the desktop, L and up for touch.
- Meta for one short fact per row: how many items a folder holds, or what changed in a file (M, +12).
Avoid
- Headings on a page: use an Outline.
- Choosing several nested options: use a Checkbox tree.
- Two or three levels of navigation: a Sidebar with groups reads faster.