Skip to main content

itemSpacing

Applicable only on "HORIZONTAL" or "VERTICAL" auto-layout frames. Determines distance between children of the frame.

Signature

itemSpacing: number

Remarks

For auto-layout frames with layoutMode set to "HORIZONTAL", this is the horizontal gap between children. For auto-layout frames with layoutMode set to "VERTICAL", this is the vertical gap between children.

Auto-layout frame with a horizontal gap between children
const parentFrame = figma.createFrame()
parentFrame.appendChild(figma.createFrame())
parentFrame.appendChild(figma.createFrame())
parentFrame.layoutMode = 'HORIZONTAL'

// Parent frame
// +------------------------------------+
// |+-----------+ +-----------+|
// || | | ||
// || Child 1 | -- 20 -- | Child 2 ||
// || | | ||
// |+-----------+ +-----------+|
// +------------------------------------+
parentFrame.itemSpacing = 20
Auto-layout frame with a vertical gap between children
const parentFrame = figma.createFrame()
parentFrame.appendChild(figma.createFrame())
parentFrame.appendChild(figma.createFrame())
parentFrame.layoutMode = 'VERTICAL'

// Parent frame
// +-------------+
// |+-----------+|
// || ||
// || Child 1 ||
// || ||
// |+-----------+|
// | | |
// | | |
// | 20 |
// | | |
// | | |
// |+-----------+|
// || ||
// || Child 2 ||
// || ||
// |+-----------+|
// +-------------+
parentFrame.itemSpacing = 20