TreeView
Used to display hierarchical data structures in an expandable tree format
Use stable unique node identifiers and separate expansion from selection. Define loading/errors for async nodes and preserve semantics through filtering and checkbox selection.
Included icon notices
The source viewer includes ICON_ATTRIBUTION.md and original notices for the icon collections used by these examples. Preserve them when redistributing examples; react-icons' wrapper license does not replace individual collection terms.
- Lucide: ISC
- Radix Icons: MIT
Installation and initialization
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0
Initialize ChakraProvider with defaultSystem and Emotion before rendering. Preserve the host React version and inspect peer compatibility. Official npm installation supplies components, not these example source files. Use the resource setup guide for locale, next-themes and framework-specific SSR; copy the selected example source separately from npm installation.
Complete native usage example
This is the actual pinned example, not a generic API mock. Copy its source closure and retain the named export. Additional imports are listed per example below.
"use client"
import { TreeView, createTreeCollection } from "@chakra-ui/react"
import { LuFile, LuFolder } from "react-icons/lu"
export const TreeViewBasic = () => {
return (
<TreeView.Root collection={collection} maxW="sm">
<TreeView.Label>Tree</TreeView.Label>
<TreeView.Tree>
<TreeView.Node
indentGuide={<TreeView.BranchIndentGuide />}
render={({ node, nodeState }) =>
nodeState.isBranch ? (
<TreeView.BranchControl>
<LuFolder />
<TreeView.BranchText>{node.name}</TreeView.BranchText>
</TreeView.BranchControl>
) : (
<TreeView.Item>
<LuFile />
<TreeView.ItemText>{node.name}</TreeView.ItemText>
</TreeView.Item>
)
}
/>
</TreeView.Tree>
</TreeView.Root>
)
}
interface Node {
id: string
name: string
children?: Node[]
}
const collection = createTreeCollection<Node>({
nodeToValue: (node) => node.id,
nodeToString: (node) => node.name,
rootNode: {
id: "ROOT",
name: "",
children: [
{
id: "node_modules",
name: "node_modules",
children: [
{ id: "node_modules/zag-js", name: "zag-js" },
{ id: "node_modules/pandacss", name: "panda" },
{
id: "node_modules/@types",
name: "@types",
children: [
{ id: "node_modules/@types/react", name: "react" },
{ id: "node_modules/@types/react-dom", name: "react-dom" },
],
},
],
},
{
id: "src",
name: "src",
children: [
{ id: "src/app.tsx", name: "app.tsx" },
{ id: "src/index.ts", name: "index.ts" },
],
},
{ id: "panda.config", name: "panda.config.ts" },
{ id: "package.json", name: "package.json" },
{ id: "renovate.json", name: "renovate.json" },
{ id: "readme.md", name: "README.md" },
],
},
})
All examples and reproduction requirements
Names identify demos, not component variant props. Copy every sourceFiles entry for the selected example. The compositions alias denotes local files, not a package. Preserve relative imports or rewrite the alias to your project's actual path. React peers are inspected separately; editor examples retain the coherent pinned Tiptap extension family.
Basic
tree-view-basic · Named export TreeViewBasic · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-basic.tsx
With Sizes
tree-view-with-sizes · Named export TreeViewWithSizes · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-with-sizes.tsx
With Variants
tree-view-with-variants · Named export TreeViewWithVariants · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-with-variants.tsx
With Colors
tree-view-with-colors · Named export TreeViewWithColors · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-with-colors.tsxvendor/apps/compositions/src/lib/color-palettes.ts
Disabled Node
tree-view-disabled-node · Named export TreeViewDisabledNode · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-disabled-node.tsx
Controlled Expansion
tree-view-controlled-expansion · Named export TreeViewControlledExpansion · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-controlled-expansion.tsx
Explicit Expand
tree-view-explicit-expand · Named export TreeViewExplicitExpand · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-explicit-expand.tsx
Expand Icon
tree-view-expand-icon · Named export TreeViewExpandIcon · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-expand-icon.tsx
Remove Indentation
tree-view-remove-indentation · Named export TreeViewRemoveIndentation · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-remove-indentation.tsx
Async
tree-view-async · Named export TreeViewAsync · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-async.tsx
With Filter
tree-view-with-filter · Named export TreeViewWithFilter · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-with-filter.tsx
Collapse Animation
tree-view-collapse-animation · Named export TreeViewCollapseAnimation · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-collapse-animation.tsx
Expand Collapse All
tree-view-expand-collapse-all · Named export TreeViewExpandCollapseAll · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 es-toolkit@1.47.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-expand-collapse-all.tsx
With Store
tree-view-with-store · Named export TreeViewWithStore · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-with-store.tsx
With Links
tree-view-with-links · Named export TreeViewWithLinks · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-with-links.tsx
Multi Select
tree-view-multi-select · Named export TreeViewMultiSelect · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-multi-select.tsx
Checkbox
tree-view-checkbox · Named export TreeViewCheckbox · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-checkbox.tsx
Mutation
tree-view-mutation · Named export TreeViewMutation · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-mutation.tsx
Custom Icon
tree-view-custom-icon · Named export TreeViewCustomIcon · original upstream example
npm install @chakra-ui/react@3.37.0 @emotion/react@11.14.0 react-icons@5.6.0
vendor/apps/compositions/src/examples/tree-view-custom-icon.tsx
Native API and source references
The source viewer retains original declarations, imports and inheritance. Ark UI event contracts, Chakra style props and recipe types stay in their native packages; this guide does not flatten or invent their defaults. Code comments remain original source, not translated prose.
npm/@chakra-ui/react@3.37.0/dist/types/components/tree-view/index.d.tsnpm/@chakra-ui/react@3.37.0/dist/types/components/tree-view/namespace.d.tsnpm/@chakra-ui/react@3.37.0/dist/types/components/tree-view/tree-view.d.ts
State and installation checks
Run strict types, the target production build and real interactions. Test labels/focus/keyboard, both themes, narrow layout, empty/loading/error states where supported and cleanup after unmount. Remote demo endpoints, uploads and downloads are constrained in the preview; configure your own services. Copying a command or reaching preview-ready does not prove installation or backend success.
Provenance and license boundaries
https://github.com/chakra-ui/chakra-ui/tree/2e7517745cff2fcde0b8012f136cf99611ff262a
These are JGuang practical bilingual notes, not a full translation of upstream MDX. Original documentation and example bytes remain in vendor. Preserve repository MIT, compositions ISC metadata and separate dependency notices. The original metadata discrepancy and any missing full notices remain explicit review items; paid Chakra Pro is excluded.