Build a layout tree
figma_build_layoutBuilds a complete nested Figma layer tree—screens, auto-layout stacks, text, shapes, components, and instances—in one call, returning node IDs, warnings, and an optional PNG preview.
Instructions
Builds a whole nested layer tree in one call: screens, auto-layout stacks, text, shapes, SVG icons, components, variants and instances. Prefer this over many figma_create_node calls. Returns ids (by "ref"), warnings for anything Figma rejected, and optionally a PNG of the result to check it.
Node spec (all fields optional except where noted):
type: frame (default) | text (default when "text" is set) | rect | ellipse | line | svg (needs "svg") | instance | component | componentSet (children become variants, named "Prop=Value")
name, ref (id handle for later nodes and the result), children: [...]
Layout: layout "row"|"column"|"none", gap (number or "auto" = space-between), padding (n | [y,x] | [t,r,b,l]), align (main axis: start|center|end|between), cross (start|center|end|baseline), wrap
Size: width/height = number | "fill" | "hug" (auto-layout frames hug by default), minWidth, maxWidth, grow
Position: x, y (in non-auto-layout parents), position "absolute" inside auto layout
Look: fill, stroke, strokeWidth (n or {top,right,bottom,left}), strokeAlign inside|center|outside, dash, radius (n | [tl,tr,br,bl]), smoothing (0-1), opacity, clip, shadow {x,y,blur,spread,color,inset} or [..], blur, backgroundBlur, visible, rotation. Colors: "#RRGGBB(AA)" or "rgba()".
Text: text, font "Family/Style" (e.g. "Inter/Semi Bold"; styles matched loosely), weight 400-900, size, lineHeight (px | "140%" | "auto"), letterSpacing (px | "-2%"), color, textAlign, decoration underline|strikethrough, textCase, maxLines, ranges [{start,end,color,weight,size,decoration}]. width "fill" or a number makes it wrap.
svg: svgColor recolors all its paths.
Tokens: bind {fill|color|stroke|gap|padding|paddingX|paddingY|radius|width|height|opacity|: "variable name"}, textStyle / fillStyle / effectStyle: "style name"
Components: componentProps [{name, type TEXT|BOOLEAN|INSTANCE_SWAP, default, layer: "layer name"}] wires a property to a layer; description
Instances: componentRef (a ref built earlier in this call) | componentId | componentKey, variant {Prop: "Value"}, properties {Name: value}, overrides {"Layer name": "new text" | {text, color, fill, visible, ...}}
props: raw Plugin API properties applied last.
Pinning: anchor {left, right, top, bottom, centerX, above: "sibling name"} positions the node against its parent's edges after the whole tree is laid out (absolute inside auto layout, constraints set), e.g. a floating button {right: 16, bottom: 16, above: "Navigation bar"} or a sheet {left: 0, bottom: 0}.
Handoff: annotation "text" | {label, category, color, properties: ["padding","itemSpacing",...]} | [..] adds native Figma annotations (shown in Dev Mode); devStatus "READY_FOR_DEV" | "COMPLETED" | {type, description} on top-level frames or sections.
Presentation: type "section" (children positioned by x/y; the section fits around them with "padding", default 120; "fill" for its background). type "arrow" {from, to (refs or ids), fromSide?, toSide?: "top", color, strokeWidth, dash, gap} draws an orthogonal connector with an arrowhead once everything is placed, for flows between screens.
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": {
"tree": "<tree>"
},
"name": "figma_build_layout"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | Left of the first top-level node; by default it goes right of existing content | |
| y | No | ||
| gap | No | Horizontal gap between top-level nodes (default 120) | |
| url | No | Figma link (or file key) of the file to edit. Needed only when the plugin is open in more than one file. | |
| tree | Yes | Root node spec, or an array of them (e.g. several screens placed side by side). | |
| page_id | No | Switch to this page first (parent defaults to it) | |
| parent_id | No | Parent frame/group/page id; defaults to the current page | |
| collection | No | Variable collection that "bind" names resolve in when several collections share names (e.g. light and dark). "name@Collection" in a bind overrides it. | |
| screenshot | No | Return a PNG of the built roots to check the result | |
| outline_depth | No | Depth of the returned layer outline | |
| screenshot_scale | No |