Tree View
A folder browser or page outline: arrow keys open, close and move, Home and End jump, typing a letter finds the next match, and the whole tree is one Tab stop.
Navigation & layoutFree184 lines · one file
The decision inside it
One tab stop, however big
Four hundred items should not mean four hundred Tab presses to get past them. Roving tabindex keeps exactly one item focusable.
Installation
How you get it
One command. The CLI writes the file into components/ui/ and installs what it needs.
npx shadcn@latest add https://layropro.com/r/treeAPI
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
itemsrequired | TreeNode[] | — |
selected | string | — |
onSelect | (id: string, node: TreeNode) => void | — |
expanded | string[] | — |
defaultExpanded | string[] | — |
onExpandedChange | (ids: string[]) => void | — |
labelrequired | string | Accessible name. |
className | string | — |
Dependencies
npm packages
clsxlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themeLifetime access
Every component, and everything we ship next.
- All 65 components, source included
- The template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.