Skip to main content

appendChildAt

Applicable only on auto-layout frames with layoutMode set to "GRID". Appends a node to the grid at the specified row and column index.

Signature

appendChildAt(node: SceneNode, rowIndex: number, columnIndex: number): void

Remarks

If the specified row or column index is out of bounds, it will throw an error. If the specified row or column index is occupied by another node, it will throw an error. If the node is already a child of the grid, it will be removed from its current position and appended to the new position.

Appending a node to a grid at a specific row and column index
// + --- + --- + --- +
// | | | |
// + --- + --- + --- +
// | | | |
// + --- + --- + --- +
// | | | |
// + --- + --- + --- +
const grid = figma.createFrame()
grid.layoutMode = 'GRID'
grid.gridRowCount = 3
grid.gridColumnCount = 3

const child1 = figma.createFrame()
const child2 = figma.createFrame()
const child2 = figma.createFrame()

// + --- + --- + --- +
// | 1 | | |
// + --- + --- + --- +
// | 2 | | |
// + --- + --- + --- +
// | 3 | | |
// + --- + --- + --- +
grid.appendChildAt(child1, 0, 0)
grid.appendChildAt(child2, 1, 0)
grid.appendChildAt(child3, 2, 0)