# TreeView

Browse a hierarchy with native disclosure and an optional selected leaf.

- Family: Data, imported from `mizu-ui` or `mizu-ui/data`
- Docs: https://mizu.user64bit.world/components/tree-view
- Source: https://github.com/0xuser64bit/mizu/blob/main/packages/mizu/src/data/Inspection.tsx

## Usage

```tsx
"use client";

import { useState } from "react";
import { TreeView } from "mizu-ui";

export function Example() {
  const [selected, setSelected] = useState("button");
  return (
    <TreeView
      selected={selected}
      onSelect={setSelected}
      nodes={[
        {
          id: "ui",
          label: "Foundation",
          children: [
            { id: "button", label: "Button.tsx" },
            { id: "badge", label: "Badge.tsx" },
          ],
        },
        { id: "styles", label: "styles.css" },
      ]}
    />
  );
}
```

## Copy it with the shadcn CLI

```sh
npx shadcn@latest init 0xuser64bit/mizu/preset # once, where there is no components.json
npx shadcn@latest add 0xuser64bit/mizu/tree-view
```

## Props

- `nodes`: `TreeNode[]`. Stable id, label and optional children.
- `selected / onSelect`: `string / function`. Optional leaf selection.

## Accessibility

Nested lists and native details; not an ARIA tree widget. Tab and Enter operate disclosures and leaf buttons. Depth is bounded at 16.

## Motion

Native disclosure.
