Skip to main content
Glama

set_layout_sizing

Define horizontal and vertical sizing modes for auto-layout frames in Figma to control element behavior and responsiveness programmatically.

Instructions

Set horizontal and vertical sizing modes for an auto-layout frame in Figma

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool 'set_layout_sizing' is registered here using server.tool(). This includes the tool name, description, input schema (Zod validation), and the handler function.
    server.tool( "set_layout_sizing", "Set horizontal and vertical sizing modes for an auto-layout frame in Figma", { nodeId: z.string().describe("The ID of the frame to modify"), layoutSizingHorizontal: z .enum(["FIXED", "HUG", "FILL"]) .optional() .describe("Horizontal sizing mode (HUG for frames/text only, FILL for auto-layout children only)"), layoutSizingVertical: z .enum(["FIXED", "HUG", "FILL"]) .optional() .describe("Vertical sizing mode (HUG for frames/text only, FILL for auto-layout children only)") }, async ({ nodeId, layoutSizingHorizontal, layoutSizingVertical }) => { try { const result = await sendCommandToFigma("set_layout_sizing", { nodeId, layoutSizingHorizontal, layoutSizingVertical }); const typedResult = result as { name: string }; // Create a message about which sizing modes were set const sizingMessages = []; if (layoutSizingHorizontal !== undefined) sizingMessages.push(`horizontal: ${layoutSizingHorizontal}`); if (layoutSizingVertical !== undefined) sizingMessages.push(`vertical: ${layoutSizingVertical}`); const sizingText = sizingMessages.length > 0 ? `layout sizing (${sizingMessages.join(', ')})` : "layout sizing"; return { content: [ { type: "text", text: `Set ${sizingText} for frame "${typedResult.name}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting layout sizing: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } );
  • The handler function executes the tool logic by sending the 'set_layout_sizing' command to the Figma plugin via WebSocket (sendCommandToFigma), processes the result, constructs a user-friendly response message detailing the changes applied to the frame, and handles any errors.
    async ({ nodeId, layoutSizingHorizontal, layoutSizingVertical }) => { try { const result = await sendCommandToFigma("set_layout_sizing", { nodeId, layoutSizingHorizontal, layoutSizingVertical }); const typedResult = result as { name: string }; // Create a message about which sizing modes were set const sizingMessages = []; if (layoutSizingHorizontal !== undefined) sizingMessages.push(`horizontal: ${layoutSizingHorizontal}`); if (layoutSizingVertical !== undefined) sizingMessages.push(`vertical: ${layoutSizingVertical}`); const sizingText = sizingMessages.length > 0 ? `layout sizing (${sizingMessages.join(', ')})` : "layout sizing"; return { content: [ { type: "text", text: `Set ${sizingText} for frame "${typedResult.name}"`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error setting layout sizing: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
  • Zod schema for input validation of the set_layout_sizing tool parameters: nodeId (required string), layoutSizingHorizontal and layoutSizingVertical (optional enums: FIXED, HUG, FILL).
    nodeId: z.string().describe("The ID of the frame to modify"), layoutSizingHorizontal: z .enum(["FIXED", "HUG", "FILL"]) .optional() .describe("Horizontal sizing mode (HUG for frames/text only, FILL for auto-layout children only)"), layoutSizingVertical: z .enum(["FIXED", "HUG", "FILL"]) .optional() .describe("Vertical sizing mode (HUG for frames/text only, FILL for auto-layout children only)") },

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