Skip to main content
Glama

set_item_spacing

Adjust spacing between elements within an auto-layout frame in Figma, enabling precise and consistent design alignment through programmatic control.

Instructions

Set distance between children in an auto-layout frame

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'set_item_spacing' MCP tool, including the schema definition and the handler function. The handler proxies the command to the Figma plugin via sendCommandToFigma 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)}`, }, ], }; } } );
  • The core handler function that executes the tool logic by sending the 'set_item_spacing' command to the underlying Figma plugin and handling the response with success or error messaging.
    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)}`, }, ], }; } }
  • Input schema using Zod validation for the tool parameters: nodeId (string, ID of the auto-layout frame) and itemSpacing (number, spacing value).
    { 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.") },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pipethedev/Talk-to-Figma-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server