Overview
Focuses the Figma viewport on a specific node by selecting it and scrolling the canvas to bring it into view. This is useful for directing user attention to a specific element or navigating to a node programmatically.Parameters
The ID of the node to focus on. The node must exist in the current document.
Return Value
Returns confirmation with the focused node’s name and ID:Usage Example
Behavior
When you callset_focus:
- The node is selected (previous selection is replaced)
- The viewport scrolls to center the node
- The node becomes visible and highlighted
Best Practices
Use
set_focus to guide users to specific elements during automated workflows or after creating/modifying nodes.Common Use Cases
- Navigating to a newly created element
- Highlighting errors or issues in designs
- Guiding users through a review process
- Showing results of search operations
- Demonstrating design changes
Code Location
Source:server.ts:2462-2491
Related Tools
- set_selections - Select multiple nodes
- get_node_info - Get node details
- get_selection - Get current selection