set_letter_spacing
Adjust letter spacing in Figma text nodes to control character spacing using pixel or percentage values for precise typography adjustments.
Instructions
Set the letter spacing of a text node in Figma
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nodeId | Yes | The ID of the text node to modify | |
| letterSpacing | Yes | Letter spacing value | |
| unit | No | Unit type (PIXELS or PERCENT) |
Implementation Reference
- Full server.tool registration including schema, description, and handler function for the 'set_letter_spacing' MCP tool. The handler sends a 'set_letter_spacing' command to the Figma plugin via websocket and formats the response.server.tool( "set_letter_spacing", "Set the letter spacing of a text node in Figma", { nodeId: z.string().describe("The ID of the text node to modify"), letterSpacing: z.number().describe("Letter spacing value"), unit: z.enum(["PIXELS", "PERCENT"]).optional().describe("Unit type (PIXELS or PERCENT)"), }, async ({ nodeId, letterSpacing, unit }) => { try { const result = await sendCommandToFigma("set_letter_spacing", { nodeId, letterSpacing, unit: unit || "PIXELS" }); const typedResult = result as { name: string, letterSpacing: { value: number, unit: string } }; return { content: [ { type: "text", text: `Updated letter spacing of node "${typedResult.name}" to ${typedResult.letterSpacing.value} ${typedResult.letterSpacing.unit}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error setting letter spacing: ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- Zod input schema defining parameters for the set_letter_spacing tool: nodeId (string), letterSpacing (number), optional unit (PIXELS or PERCENT).{ nodeId: z.string().describe("The ID of the text node to modify"), letterSpacing: z.number().describe("Letter spacing value"), unit: z.enum(["PIXELS", "PERCENT"]).optional().describe("Unit type (PIXELS or PERCENT)"),
- Part of FigmaCommand union type listing 'set_letter_spacing' as a valid command sent to Figma plugin.| "set_letter_spacing"