findAll
Searches this entire subtree (this node's children, its children's children, etc). Returns all nodes for which callback
returns true.
Supported on:
Signature
findAll(callback?: (node: SceneNode) => boolean): SceneNode[]
Parameters
callback
A function that evaluates whether to return the provided node
. If this argument is omitted, findAll
returns all nodes in the subtree.
Remarks
Nodes are included in back-to-front order. Parents always appear before their children, and children appear in same relative order before their children, and children appear in same relative order as in the children
array.
This traversal method is known as "pre-order traversal".
Note that the node this method is called on is not included.
Example: find all nodes whose name is "Color":
const colors = figma.currentPage.findAll(n => n.name === "Color")
caution
⚠ Large documents in Figma can have tens of thousands of nodes. Be careful using this function as it could be very slow.
If you only need to search immediate children, it is much faster to call node.children.filter(callback)
or node.findChildren(callback)
.
Please refer to our recommendations for how to optimize document traversals.