set_axis_align
Align primary and counter axes in Figma auto-layout frames programmatically, enabling precise adjustments through automated design tasks.
Instructions
Set primary and counter axis alignment for an auto-layout frame in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/talk_to_figma_mcp/server.ts:2194-2245 (registration)Registration of the MCP tool 'set_axis_align' including input schema and execution handler. The handler forwards the command to the Figma plugin via sendCommandToFigma.server.tool( "set_axis_align", "Set primary and counter axis alignment for an auto-layout frame in Figma", { nodeId: z.string().describe("The ID of the frame to modify"), primaryAxisAlignItems: z .enum(["MIN", "MAX", "CENTER", "SPACE_BETWEEN"]) .optional() .describe("Primary axis alignment (MIN/MAX = left/right in horizontal, top/bottom in vertical). Note: When set to SPACE_BETWEEN, itemSpacing will be ignored as children will be evenly spaced."), counterAxisAlignItems: z .enum(["MIN", "MAX", "CENTER", "BASELINE"]) .optional() .describe("Counter axis alignment (MIN/MAX = top/bottom in horizontal, left/right in vertical)") }, async ({ nodeId, primaryAxisAlignItems, counterAxisAlignItems }) => { try { const result = await sendCommandToFigma("set_axis_align", { nodeId, primaryAxisAlignItems, counterAxisAlignItems }); const typedResult = result as { name: string }; // Create a message about which alignments were set const alignMessages = []; if (primaryAxisAlignItems !== undefined) alignMessages.push(`primary: ${primaryAxisAlignItems}`); if (counterAxisAlignItems !== undefined) alignMessages.push(`counter: ${counterAxisAlignItems}`); const alignText = alignMessages.length > 0 ? `axis alignment (${alignMessages.join(', ')})` : "axis alignment"; return { content: [ { type: "text", text: `Set ${alignText} for frame "${typedResult.name}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting axis alignment: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
- Handler function that executes the tool logic by sending 'set_axis_align' command to Figma plugin and formats the response.async ({ nodeId, primaryAxisAlignItems, counterAxisAlignItems }) => { try { const result = await sendCommandToFigma("set_axis_align", { nodeId, primaryAxisAlignItems, counterAxisAlignItems }); const typedResult = result as { name: string }; // Create a message about which alignments were set const alignMessages = []; if (primaryAxisAlignItems !== undefined) alignMessages.push(`primary: ${primaryAxisAlignItems}`); if (counterAxisAlignItems !== undefined) alignMessages.push(`counter: ${counterAxisAlignItems}`); const alignText = alignMessages.length > 0 ? `axis alignment (${alignMessages.join(', ')})` : "axis alignment"; return { content: [ { type: "text", text: `Set ${alignText} for frame "${typedResult.name}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting axis alignment: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
- Input schema using Zod for validating tool parameters: nodeId (required), primaryAxisAlignItems and counterAxisAlignItems (optional enums).{ nodeId: z.string().describe("The ID of the frame to modify"), primaryAxisAlignItems: z .enum(["MIN", "MAX", "CENTER", "SPACE_BETWEEN"]) .optional() .describe("Primary axis alignment (MIN/MAX = left/right in horizontal, top/bottom in vertical). Note: When set to SPACE_BETWEEN, itemSpacing will be ignored as children will be evenly spaced."), counterAxisAlignItems: z .enum(["MIN", "MAX", "CENTER", "BASELINE"]) .optional() .describe("Counter axis alignment (MIN/MAX = top/bottom in horizontal, left/right in vertical)") },