set_item_spacing
Adjust spacing between elements in a Figma auto-layout frame to control visual hierarchy and alignment in designs.
Instructions
Set distance between children in an auto-layout frame
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"nodeId": "<nodeId>",
"itemSpacing": "<itemSpacing>"
},
"name": "set_item_spacing"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the frame to modify | |
| itemSpacing | Yes | Distance between children. Note: This value will be ignored if primaryAxisAlignItems is set to SPACE_BETWEEN. |
Implementation Reference
- MCP tool registration, schema, and handler for 'set_item_spacing'. The handler proxies the command to the Figma plugin via sendCommandToFigma, which sends it over websocket, and formats the response.
server.tool( "set_item_spacing", "Set distance between children in an auto-layout frame", { nodeId: z.string().describe("The ID of the frame to modify"), itemSpacing: z.number().describe("Distance between children. Note: This value will be ignored if primaryAxisAlignItems is set to SPACE_BETWEEN.") }, async ({ nodeId, itemSpacing }) => { try { const result = await sendCommandToFigma("set_item_spacing", { nodeId, itemSpacing }); const typedResult = result as { name: string }; return { content: [ { type: "text", text: `Set item spacing to ${itemSpacing} for frame "${typedResult.name}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting item spacing: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );