Skip to content
v0.2.10

Tree

A selectable application hierarchy with independent expansion and keyboard focus.

Preview
Project files
Source
Components
Button.tsx
Input.tsx
tokens.json
Documentation
Introduction.md
README.md
Archived

Use Tree

Tree is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
tree.tsxTSX
"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

PropValuesDefault
labelstringRequired
hideLabelboolean—
itemsreadonly TreeItem[]Required
valuestring | readonly string[]—
defaultValuestring | readonly string[]—
onValueChange(value: string | string[]) => void—
multipleboolean—
expandedValuesreadonly string[]—
defaultExpandedValuesreadonly string[]—
onExpandedValuesChange(values: string[]) => void—
disabledboolean—
readOnlyboolean—
controlSize"sm" | "md" | "lg" | "xl"—
emptyMessagestring—
loadingMessagestring—
unloadedMessagestring—
readOnlyMessagestring—
Native HTML propsOmit<HTMLAttributes<HTMLDivElement>, "children" | "onSelect" | "defaultValue" | "onChange">Forwarded
View TypeScript source