Writing¶
figma_get_selection¶
What is selected in Figma right now: the ids, names, types and sizes of the nodes. This is the right first step for 'move this' and 'change the selected one' — the nodeId comes from the response. Requires a running Snail Bridge plugin.
Takes no parameters.
JSON Schema
{
"type": "object",
"properties": {}
}
figma_move_node¶
Moves a node. The x and y coordinates are relative to the parent, exactly as the Figma Plugin API understands them. To move it '10 pixels to the right', first read the current position (figma_get_component or figma_get_selection) and add the offset to it. Requires the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
nodeId |
string |
yes | — | Node id, for example '1:234'. |
x |
number |
yes | — | New X coordinate relative to the parent. |
y |
number |
yes | — | New Y coordinate relative to the parent. |
JSON Schema
{
"type": "object",
"properties": {
"nodeId": {
"description": "Node id, for example \u00271:234\u0027.",
"type": "string"
},
"x": {
"description": "New X coordinate relative to the parent.",
"type": "number"
},
"y": {
"description": "New Y coordinate relative to the parent.",
"type": "number"
}
},
"required": [
"nodeId",
"x",
"y"
]
}
figma_resize_node¶
Resizes a node. With withConstraints=true Figma recalculates the nested elements by their constraints — usually that is what you want for frames. Requires the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
nodeId |
string |
yes | — | Node id, for example '1:234'. |
width |
number |
yes | — | New width in pixels. |
height |
number |
yes | — | New height in pixels. |
withConstraints |
boolean |
— | true |
Recalculate the children by their constraints. |
JSON Schema
{
"type": "object",
"properties": {
"nodeId": {
"description": "Node id, for example \u00271:234\u0027.",
"type": "string"
},
"width": {
"description": "New width in pixels.",
"type": "number"
},
"height": {
"description": "New height in pixels.",
"type": "number"
},
"withConstraints": {
"description": "Recalculate the children by their constraints.",
"type": "boolean",
"default": true
}
},
"required": [
"nodeId",
"width",
"height"
]
}
figma_set_fills¶
Sets the fills of a node. The fills format is an array of Figma Paint in JSON, for example [{"type":"SOLID","color":{"r":1,"g":0,"b":0},"opacity":1}]. Channel components are fractions from 0 to 1, not 0-255. Requires the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
nodeId |
string |
yes | — | Node id, for example '1:234'. |
fills |
string |
yes | — | Array of Paint as a JSON string. |
JSON Schema
{
"type": "object",
"properties": {
"nodeId": {
"description": "Node id, for example \u00271:234\u0027.",
"type": "string"
},
"fills": {
"description": "Array of Paint as a JSON string.",
"type": "string"
}
},
"required": [
"nodeId",
"fills"
]
}
figma_set_text¶
Changes the text in a TEXT node. Careful: when the node belongs to a component instance and the text is driven by a component property, the edit may not apply — use figma_set_instance_properties then. Requires the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
nodeId |
string |
yes | — | TEXT node id, for example '1:234'. |
text |
string |
yes | — | New text. |
JSON Schema
{
"type": "object",
"properties": {
"nodeId": {
"description": "TEXT node id, for example \u00271:234\u0027.",
"type": "string"
},
"text": {
"description": "New text.",
"type": "string"
}
},
"required": [
"nodeId",
"text"
]
}
figma_execute¶
Runs arbitrary JavaScript in the Figma plugin sandbox: the whole figma object (Plugin API) is available. The universal tool for what the specialised commands do not cover. The code runs as the body of an async function; return a value with return. The asynchronous Figma methods (loadFontAsync, getNodeByIdAsync, loadAllPagesAsync) must be awaited. Requires the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
code |
string |
yes | — | JavaScript code. Example: const n = await figma.getNodeByIdAsync('1:2'); return n.name; |
timeoutMs |
integer |
— | 15000 |
Execution timeout in milliseconds. |
JSON Schema
{
"type": "object",
"properties": {
"code": {
"description": "JavaScript code. Example: const n = await figma.getNodeByIdAsync(\u00271:2\u0027); return n.name;",
"type": "string"
},
"timeoutMs": {
"description": "Execution timeout in milliseconds.",
"type": "integer",
"default": 15000
}
},
"required": [
"code"
]
}
figma_get_selection_colors¶
Every color used in the current selection, with the styles they come from — the quick token audit: select a screen, see which paints are loose values instead of styles or variables. Returns null-ish when nothing is selected. Requires the plugin.
Takes no parameters.
JSON Schema
{
"type": "object",
"properties": {}
}
figma_sort_styles¶
Reorders the local styles panel: alphabetically by default, or by an explicit comma-separated id list. styleType is PAINT, TEXT, EFFECT or GRID; ids come from figma_get_styles. Folder prefixes (Brand/…) sort with their names. Requires the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
styleType |
string |
yes | — | Style type: PAINT, TEXT, EFFECT or GRID. |
order |
string? |
— | null |
Comma-separated style ids in the desired order; empty sorts alphabetically. |
JSON Schema
{
"type": "object",
"properties": {
"styleType": {
"description": "Style type: PAINT, TEXT, EFFECT or GRID.",
"type": "string"
},
"order": {
"description": "Comma-separated style ids in the desired order; empty sorts alphabetically.",
"type": [
"string",
"null"
],
"default": null
}
},
"required": [
"styleType"
]
}
figma_commit_undo¶
Closes the current undo group: everything changed since the previous commit becomes a single Ctrl+Z step for the human working in the same file. Call it after a finished batch of mutations, not after every small edit. Requires the plugin.
Takes no parameters.
JSON Schema
{
"type": "object",
"properties": {}
}
figma_create_style¶
Creates a local style. styleType is PAINT, TEXT, EFFECT or GRID; properties is JSON with the style contents: paints for PAINT, fontName/fontSize/lineHeight and the other text fields for TEXT, effects for EFFECT, layoutGrids for GRID. A slash in the name makes a folder: Brand/Primary. Existing styles are read by figma_get_styles. Requires the plugin.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
styleType |
string |
yes | — | Style type: PAINT, TEXT, EFFECT or GRID. |
name |
string |
yes | — | Style name; a slash makes a folder: Brand/Primary. |
properties |
string? |
— | null |
Style contents as JSON, keyed by type: paints, text fields, effects or layoutGrids. |
JSON Schema
{
"type": "object",
"properties": {
"styleType": {
"description": "Style type: PAINT, TEXT, EFFECT or GRID.",
"type": "string"
},
"name": {
"description": "Style name; a slash makes a folder: Brand/Primary.",
"type": "string"
},
"properties": {
"description": "Style contents as JSON, keyed by type: paints, text fields, effects or layoutGrids.",
"type": [
"string",
"null"
],
"default": null
}
},
"required": [
"styleType",
"name"
]
}
figma_get_status¶
The state of the bridge to Figma: whether the plugin is connected, which files are visible, which of them is active. Call it first when the write tools answer 'the plugin is not connected'.
Takes no parameters.
JSON Schema
{
"type": "object",
"properties": {}
}