Skip to main content

findAllWithCriteria

Searches this entire subtree (this node's children, its children's children, etc). Returns all nodes that satisfy any of the types defined in the criteria.

Signature

findAllWithCriteria<T extends NodeType[]>(criteria: { types: T }): Array<{ type: T[number] } & SceneNode>

Parameters

criteria

An object containing the node types to search, such as 'FRAME', 'TEXT', etc...

Remarks

This is a faster but more limited search compared to findAll, which lets you search nodes based on any logic you can include in a callback.

When paired with figma.skipInvisibleInstanceChildren = true, this method can be hundreds of times faster in large documents with tens of thousands of nodes.

The return value is narrowly typed to match the provided types, which makes it much easier to use node-type-specific properties. For example, node.findAllWithCriteria({ types: ['TEXT'] }) will return TextNode[] instead of the more generic SceneNode[] from findAll.

Nodes are included in back-to-front order, which is the same order as in findAll. 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 component and component set nodes in the current page:

const nodes = figma.currentPage.findAllWithCriteria({
types: ['COMPONENT', 'COMPONENT_SET']
})