The TaffyTree Object

The TaffyTree object represents the entire layout tree and serves as the entry point for layout calculations.

Node IDs are bigint values owned by the tree that created them. Pass only live IDs from that same tree; stop using an ID after removing its node or clearing the tree. See Error Handling for checked child-index errors and node-ID preconditions.

Key Responsibilities

  • Node Management: Creating, adding, removing, and inserting nodes.
  • Tree Hierarchy: Maintaining the parent-child relationships between nodes.
  • Computation: Invoking the layout algorithm via computeLayout or computeLayoutWithMeasure.
  • Result Retrieval: Storing and providing access to the computed results for each node.

Usage

const tree = new TaffyTree(); // Create nodes const child = tree.newLeaf(new Style()); const root = tree.newWithChildren(new Style(), [child]); // Compute layout tree.computeLayout(root, { width: 500, height: 500 }); // Access results const layout = tree.getLayout(child);

Next Steps

© 2026 ByteLand Technology Limited