# Tree

A selectable application hierarchy with independent expansion and keyboard focus.

Connect Flood once using [the installation guide](https://flood.md/docs/installation). Then import the components you use; no per-component add command is needed.

## Example

```tsx
"use client";

import { FloodRoot, Tree } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <Tree label="Project files" items={[{value:"source",label:"Source",children:[{value:"button",label:"Button.tsx"}]}]} />
    </FloodRoot>
  );
}
```

## Design notes

- Tree uses tree/treeitem/group semantics, logical arrows, Home/End and typeahead. Moving focus does not select an item. Enter/Space explicitly selects; multiple selection does not cascade.
- Items have globally unique values. Expansion uses expandedValues/defaultExpandedValues/onExpandedValuesChange; selection uses value/defaultValue/onValueChange. Controlled refusal preserves the host state.
- Read-only allows browsing without selecting. Disabled items remain discoverable but cannot select or expand. hasChildren/loading represent host-owned deferred branches; no fetching or virtualization is built in.
- Application selection writes no form values. Use NavigationTree for ordinary native links. Introduced in 0.2.7.

## API reference

| Prop | Values | Default |
| --- | --- | --- |
| `label` | `string` | `Required` |
| `hideLabel` | `boolean` | `—` |
| `items` | `readonly TreeItem[]` | `Required` |
| `value` | `string \| readonly string[]` | `—` |
| `defaultValue` | `string \| readonly string[]` | `—` |
| `onValueChange` | `(value: string \| string[]) => void` | `—` |
| `multiple` | `boolean` | `—` |
| `expandedValues` | `readonly string[]` | `—` |
| `defaultExpandedValues` | `readonly string[]` | `—` |
| `onExpandedValuesChange` | `(values: string[]) => void` | `—` |
| `disabled` | `boolean` | `—` |
| `readOnly` | `boolean` | `—` |
| `controlSize` | `"sm" \| "md" \| "lg" \| "xl"` | `—` |
| `emptyMessage` | `string` | `—` |
| `loadingMessage` | `string` | `—` |
| `unloadedMessage` | `string` | `—` |
| `readOnlyMessage` | `string` | `—` |
| `Native HTML props` | `Omit<HTMLAttributes<HTMLDivElement>, "children" \| "onSelect" \| "defaultValue" \| "onChange">` | `Forwarded` |
