# Tree sidebar

A shadcn/ui app sidebar with teams, folders and pages nested three levels deep, where every level lines up with its parent at any icon or row size.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available for the docs, pricing and about pages: append `.md` to the URL or send an `Accept: text/markdown` header (the home page answers the header too). An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

## At a glance

- **Good for:** Issue trackers with teams and projects; Docs and wikis with nested pages; File and folder navigation in SaaS apps; Workspaces with teams, areas and views
- **Category:** Navigation · **Type:** Sidebars · **Style:** Motion, Minimal, Dark mode
- **See it:** [Live preview](https://www.craftui.space/docs/blocks/tree-sidebar) · [Screenshot](https://www.craftui.space/llms.md/preview/tree-sidebar.87897c09.jpg)

![Tree sidebar](https://www.craftui.space/llms.md/preview/tree-sidebar.87897c09.jpg)

## Install

```bash
pnpm dlx shadcn@latest add https://www.craftui.space/r/tree-sidebar.json
```

This is a paid item (BLK-05GVRZ): the install needs a craftUI plan or a purchase of it. Signed in, the docs page gives your personal install command. Plans: https://www.craftui.space/pricing

## Usage

```tsx
import TreeSidebar from "@/components/blocks/tree-sidebar/tree-sidebar";

export default function Page() {
  return <TreeSidebar />;
}
```

With no props it renders with demo content; pass your own through the props below.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `workspaces` | `Workspace[]` | `DEFAULT_WORKSPACES` | Workspaces in the header's switcher; the first is current. |
| `top` | `NavItem[]` | `DEFAULT_TOP` | Links above the tree, with icons (Inbox, My issues). |
| `treeLabel` | `string` | `"Your teams"` | Heading above the tree, e.g. "Your teams". |
| `tree` | `TreeNode[]` | `DEFAULT_TREE` | The tree: up to three levels. Rows with children fold; the rest are links. |
| `user` | `SidebarUser` | `DEFAULT_USER` | The signed-in person, shown in the footer. |
| `defaultActive` | `string` | `"product-active"` | Id of the link that starts active. Defaults to the first top link. |
| `onNavigate` | `(id: string) => void` | — | Called with the id of each link picked (not when a row folds). |
| `onSwitchWorkspace` | `(id: string) => void` | — | Called when a workspace is picked in the switcher. |
| `onCreateWorkspace` | `() => void` | — | Called from the switcher's "Create workspace". |
| `onCreate` | `() => void` | — | Called from the header's new-team button. |
| `onSettings` | `() => void` | — | Called from the footer's settings button. |
| `children` | `React.ReactNode` | — | The page beside the sidebar. Defaults to placeholder content. |
| `className` | `string` | — | Height and placement, e.g. "h-svh" (the default) or "h-[40rem]". |
| `style` | `React.CSSProperties` | — | Sizes for this one sidebar, overriding the five numbers in sidebar-vars.ts, e.g. `{ "--sb-icon": "1.25rem", "--sb-row": "2.5rem" }`. Everything else follows from them, so every level stays on its line. |

### `Workspace`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id. |
| `name` (required) | `string` | Name shown in the header, e.g. "Northwind". |
| `color` (required) | `string` | Background of the workspace's monogram, any CSS colour. |

### `NavItem`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id; matched against the active id. |
| `label` (required) | `string` | Text in the row. |
| `icon` (required) | `IconSvgElement` | A Hugeicons icon from `@hugeicons/core-free-icons`. |
| `href` | `string` | Link target. Without it the row only changes the active item. |

### `TreeNode`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Unique id across the whole tree; matched against the active id. |
| `label` (required) | `string` | Text in the row, e.g. "Issues". |
| `icon` | `IconSvgElement` | A Hugeicons icon from `@hugeicons/core-free-icons`. Leave out for a text-only row. |
| `color` | `string` | The team's colour, any CSS colour: draws `duotone` in it, or a coloured square when there's no `duotone`. |
| `duotone` | `Icon` | A Phosphor icon (`@phosphor-icons/react`) drawn duotone in `color`: the line in the colour, the fill in the same colour at 20%. For teams and projects; takes the place of `icon`. |
| `href` | `string` | Link target, for a row without children. Without it the row only changes the active item. |
| `children` | `TreeNode[]` | Rows nested under this one. Three levels at most: children of a third-level row are ignored. |
| `defaultOpen` | `boolean` | Whether a row with children starts open. Defaults to closed. |
| `count` | `number` | A number on the right spine, for a row without children (items in a view, results for a filter). |
| `disabled` | `boolean` | Shown dimmed and can't be picked (a view with nothing in it yet). |

### `SidebarUser`

| Field | Type | Description |
| --- | --- | --- |
| `name` (required) | `string` | Full name, e.g. "Maya Chen". |
| `avatar` | `string` | Photo URL; the initials show while it loads or when it's missing. |

## Files

The install adds:

- `components/blocks/tree-sidebar/tree-sidebar.tsx`
- `components/blocks/tree-sidebar/tree-rows.tsx`
- `components/blocks/tree-sidebar/workspace-switcher.tsx`
- `components/blocks/tree-sidebar/nav-data.ts`
- `components/blocks/tree-sidebar/sidebar-vars.ts`
- `components/blocks/tree-sidebar/DESIGN.md`

npm dependencies (installed for you): `@hugeicons/core-free-icons`, `@hugeicons/react`, `@phosphor-icons/react`.

shadcn/ui components it uses (the shadcn CLI adds any that are missing): `avatar`, `collapsible`, `dropdown-menu`, `sidebar`.