Takeoff Tree View
ASecurity`TreeView` shows a hierarchy as a nested list. Branches expand and collapse, items can be selected, and with `checkable` every item gets a checkbox whose state cascades through the tree. Behavior — the value models, the WAI-ARIA tree keyboard and the ARIA wiring — is Spar's `Tree`; the look follows the Takeoff design. **When to use:** browsing or picking from a hierarchy: a file tree, category or organisation structure, nested permissions. Not this — collapsible page sections are `Accordion`;...
- 3 stars
- 0 votes
- 0 copies
- 3 views
- Added December 4, 2026
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add turkishtechnology/takeoff-v2 --skill takeoff-tree-view --agent claude-codeAre you the author of Takeoff Tree View?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/turkishtechnology-takeoff-tree-view)---
name: takeoff-tree-view
description:
'Build a TreeView (a hierarchical, expandable list: folders, categories,
organisational units — expand/collapse branches, single or multiple selection,
cascading checkboxes, children loaded on demand) — the TreeView from
@takeoff-ui/react-spar (Takeoff UI / Spar React). Trigger when showing a file
or folder tree, a category or org hierarchy, a nested permission list with
checkboxes, or a lazily loaded tree. Use this skill WHENEVER building, adding,
importing, styling, or fixing a TreeView / tree in a React app that uses
@takeoff-ui/react-spar / Takeoff / Spar. Not for collapsible content sections
(use Accordion) or app navigation (use Sidebar).'
---
# TreeView — @takeoff-ui/react-spar
`TreeView` shows a hierarchy as a nested list. Branches expand and collapse,
items can be selected, and with `checkable` every item gets a checkbox whose
state cascades through the tree. Behavior — the value models, the WAI-ARIA tree
keyboard and the ARIA wiring — is Spar's `Tree`; the look follows the Takeoff
design.
**When to use:** browsing or picking from a hierarchy: a file tree, category or
organisation structure, nested permissions. Not this — collapsible page sections
are `Accordion`; the app's side navigation is `Sidebar`.
## Setup
Requires the Takeoff provider + token CSS mounted once at the app root (see the
`takeoff-ui` skill or the installation docs). Then import:
```tsx
import { TreeView } from '@takeoff-ui/react-spar';
```
## Compound parts
- `TreeView` — root `<ul role="tree">`. Holds `size`, `type`, `showPointer` and
every value model (expanded, selection, checked).
- `TreeView.Item` — `<li role="treeitem">`; `value` (unique in the tree),
`disabled`, `hasChildren` (lazy branches), `textValue` (type-ahead text).
- `TreeView.ItemContent` — the visible row. Renders the expand caret (branches
only; a spinner while loading) and the checkbox (`checkable` trees) itself,
before its children. Children may be a function of the item state.
- `TreeView.ItemIcon` — decorative leading icon (`aria-hidden`).
- `TreeView.ItemLabel` — the item text (truncates with an ellipsis).
- `TreeView.Group` — nested `<ul role="group">` of child items, hidden while the
parent is collapsed; draws the guide line.
## Basic usage
```tsx
<TreeView aria-label="Documents" defaultExpanded={['flights']}>
<TreeView.Item value="flights">
<TreeView.ItemContent>
<TreeView.ItemIcon>
<FolderCopyIconOutlinedRounded />
</TreeView.ItemIcon>
<TreeView.ItemLabel>Flights</TreeView.ItemLabel>
</TreeView.ItemContent>
<TreeView.Group>
<TreeView.Item value="manifest">
<TreeView.ItemContent>
<TreeView.ItemLabel>Cargo manifest</TreeView.ItemLabel>
</TreeView.ItemContent>
</TreeView.Item>
</TreeView.Group>
</TreeView.Item>
</TreeView>
```
## Examples
### Controlled multiple selection in a bordered container
```tsx
const [selected, setSelected] = useState<string[]>([]);
<TreeView
aria-label="Stations"
type="divided"
size="small"
selectionMode="multiple"
value={selected}
onValueChange={setSelected}
>
…
</TreeView>;
```
### Cascading checkboxes reporting only leaves
```tsx
<TreeView
aria-label="Permissions"
checkable
selectionMode="none"
checkStrategy="leaf"
defaultChecked={['reports']}
onCheckedChange={setChecked}
>
…
</TreeView>
```
### Lazy children
```tsx
<TreeView
aria-label="Archive"
expanded={expanded}
onExpandedChange={setExpanded}
onLoadChildren={value => fetchChildren(value).then(add)}
>
<TreeView.Item value="2024" hasChildren>
<TreeView.ItemContent>
<TreeView.ItemLabel>2024</TreeView.ItemLabel>
</TreeView.ItemContent>
{children['2024'] && (
<TreeView.Group>{children['2024'].map(renderItem)}</TreeView.Group>
)}
</TreeView.Item>
</TreeView>
```
### Caret-only expansion with a trailing badge
```tsx
<TreeView aria-label="Inbox" toggleTrigger="icon" showPointer={false}>
<TreeView.Item value="inbox">
<TreeView.ItemContent>
<TreeView.ItemLabel>Inbox</TreeView.ItemLabel>
<Badge size="small">12</Badge>
</TreeView.ItemContent>
<TreeView.Group>…</TreeView.Group>
</TreeView.Item>
</TreeView>
```
## Key props
### `TreeView` (root)
| Prop | Type | Default | Notes |
| --------------------------------------------------- | ------------------------------------- | ---------- | -------------------------------------------------------- |
| `size` | `'small' \| 'base' \| 'large'` | `'base'` | Row padding, text and icon size. |
| `type` | `'basic' \| 'divided' \| 'light'` | `'basic'` | No container / bordered / bordered on light background. |
| `showPointer` | `boolean` | `true` | Brand bar at the start of selected rows. |
| `selectionMode` | `'single' \| 'multiple' \| 'none'` | `'single'` | How pressing an item changes the selection. |
| `value` / `defaultValue` / `onValueChange` | `string[]` | `[]` | Selected item values. |
| `expanded` / `defaultExpanded` / `onExpandedChange` | `string[]` | `[]` | Expanded branch values. |
| `checkable` | `boolean` | `false` | Adds a checkbox (`aria-checked`) to every item. |
| `checked` / `defaultChecked` / `onCheckedChange` | `string[]` | `[]` | Checked item values. |
| `checkStrategy` | `'all' \| 'leaf' \| 'independent'` | `'all'` | Cascade, and which values are reported. |
| `toggleTrigger` | `'item' \| 'icon'` | `'item'` | Whether pressing the row or only the caret expands. |
| `onLoadChildren` | `(value) => void \| Promise<unknown>` | - | Expanding an empty `hasChildren` branch; pending = busy. |
| `disabled` | `boolean` | `false` | Disables every item. |
### Parts
| Part | Prop | Notes |
| ---------------------- | ------------------------------------ | ------------------------------------------------------------ |
| `TreeView.Item` | `value`, `disabled`, `hasChildren` | `disabled` covers descendants; `textValue` for type-ahead. |
| `TreeView.ItemContent` | `children` (node or render function) | Render function gets `{ isExpanded, isSelected, level, … }`. |
| `TreeView.ItemIcon` | `children` | Decorative icon, always `aria-hidden`. |
Every part takes `classNames` / `slotProps`; `ItemContent` slots are `root`,
`indicator`, `spinner`, `checkbox`, `checkboxIcon`. Full props, events, data
attributes & type definitions: see `references/full-docs.md`.
## Accessibility
- Give the tree an `aria-label` or `aria-labelledby`.
- Roving tabindex: one item is tabbable. Arrow keys move, `ArrowRight` /
`ArrowLeft` expand / collapse, `Home` / `End`, `Enter` presses, `Space` checks
(or selects), `*` expands siblings, typing jumps by text. `Shift` + arrows and
`Ctrl`/`Cmd` + `A` extend a `multiple` selection.
- The caret, checkbox and item icon are decorative; the item announces
`aria-expanded`, `aria-selected`, `aria-checked` (`mixed`) and `aria-busy`.
## Reference
- Full component docs (Copy page): `references/full-docs.md`
- Live docs: https://v2.takeoffui.com/docs/components/tree-view
- Source: `packages/react-spar/src/components/tree-view/`
- Spar primitive: `packages/spar/src/components/Tree/`
Files in this skill
- SKILL.md
- references/full-docs.md
Attribution
Related skills
View all in design →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.