set_layout_mode
Configure auto-layout settings for Figma frames by setting layout direction and wrap behavior to organize design elements systematically.
Instructions
Set the layout mode and wrap behavior of a frame in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the frame to modify | |
| layoutMode | Yes | Layout mode for the frame | |
| layoutWrap | No | Whether the auto-layout frame wraps its children |
Implementation Reference
- Handler function for the 'set_layout_mode' MCP tool. Forwards the request to the Figma plugin via sendCommandToFigma and formats the response.async ({ nodeId, layoutMode, layoutWrap }) => { try { const result = await sendCommandToFigma("set_layout_mode", { nodeId, layoutMode, layoutWrap: layoutWrap || "NO_WRAP" }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Set layout mode of frame "${typedResult.name}" to ${layoutMode}${layoutWrap ? ` with ${layoutWrap}` : ''}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting layout mode: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
- Zod input schema defining parameters for the 'set_layout_mode' tool: nodeId (required string), layoutMode (enum: NONE/HORIZONTAL/VERTICAL), layoutWrap (optional enum: NO_WRAP/WRAP).nodeId: z.string().describe("The ID of the frame to modify"), layoutMode: z.enum(["NONE", "HORIZONTAL", "VERTICAL"]).describe("Layout mode for the frame"), layoutWrap: z.enum(["NO_WRAP", "WRAP"]).optional().describe("Whether the auto-layout frame wraps its children") },
- src/talk_to_figma_mcp/server.ts:2102-2137 (registration)MCP tool registration via server.tool call, including name, description, schema, and handler function.server.tool( "set_layout_mode", "Set the layout mode and wrap behavior of a frame in Figma", { nodeId: z.string().describe("The ID of the frame to modify"), layoutMode: z.enum(["NONE", "HORIZONTAL", "VERTICAL"]).describe("Layout mode for the frame"), layoutWrap: z.enum(["NO_WRAP", "WRAP"]).optional().describe("Whether the auto-layout frame wraps its children") }, async ({ nodeId, layoutMode, layoutWrap }) => { try { const result = await sendCommandToFigma("set_layout_mode", { nodeId, layoutMode, layoutWrap: layoutWrap || "NO_WRAP" }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Set layout mode of frame "${typedResult.name}" to ${layoutMode}${layoutWrap ? ` with ${layoutWrap}` : ''}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting layout mode: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );