Skip to main content

Overview

Create a new frame in Figma with specified position, size, and extensive styling and layout options. Frames are container elements that can hold other elements and support auto-layout properties.

Parameters

Position & Size

number
required
X position of the frame
number
required
Y position of the frame
number
required
Width of the frame
number
required
Height of the frame

Basic Properties

string
Optional name for the frame. Defaults to “Frame” if not provided.
string
Optional parent node ID to append the frame to. If not provided, the frame is created in the current selection or page.

Fill & Stroke

object
Fill color in RGBA format. Defaults to white {r: 1, g: 1, b: 1, a: 1} if not provided.Properties:
  • r (number, 0-1): Red component
  • g (number, 0-1): Green component
  • b (number, 0-1): Blue component
  • a (number, 0-1, optional): Alpha/opacity component
object
Stroke color in RGBA format. Optional.Properties:
  • r (number, 0-1): Red component
  • g (number, 0-1): Green component
  • b (number, 0-1): Blue component
  • a (number, 0-1, optional): Alpha/opacity component
number
Stroke weight (border thickness) in pixels. Must be positive.

Auto-Layout Properties

enum
Auto-layout mode for the frame.Options: "NONE", "HORIZONTAL", "VERTICAL"
enum
Whether the auto-layout frame wraps its children.Options: "NO_WRAP", "WRAP"
number
Top padding for auto-layout frame in pixels.
number
Right padding for auto-layout frame in pixels.
number
Bottom padding for auto-layout frame in pixels.
number
Left padding for auto-layout frame in pixels.
enum
Primary axis alignment for auto-layout frame.Options: "MIN", "MAX", "CENTER", "SPACE_BETWEEN"Note: When set to SPACE_BETWEEN, itemSpacing will be ignored as children will be evenly spaced.
enum
Counter axis alignment for auto-layout frame.Options: "MIN", "MAX", "CENTER", "BASELINE"
enum
Horizontal sizing mode for auto-layout frame.Options: "FIXED", "HUG", "FILL"
enum
Vertical sizing mode for auto-layout frame.Options: "FIXED", "HUG", "FILL"
number
Distance between children in auto-layout frame in pixels.Note: This value will be ignored if primaryAxisAlignItems is set to SPACE_BETWEEN.

Return Type

Returns an object with:
  • name (string): The name of the created frame
  • id (string): The unique ID of the created frame (use this as parentId to add children)

Usage Examples

Basic Frame

Create a simple frame with default white background:

Frame with Custom Fill Color

Create a frame with a blue background:

Frame with Border

Create a frame with stroke (border):

Vertical Auto-Layout Frame

Create a frame with vertical auto-layout:

Horizontal Auto-Layout Frame with Space Between

Create a horizontal frame with space-between alignment:

Nested Frames

Create a frame hierarchy by using the parent’s ID:

Notes

  • Frames are the primary container type in Figma and support auto-layout
  • Use the returned id as parentId when creating child elements
  • Colors use RGBA format with values between 0 and 1 (not 0-255)
  • When primaryAxisAlignItems is set to SPACE_BETWEEN, the itemSpacing property is ignored
  • Auto-layout properties only take effect when layoutMode is set to HORIZONTAL or VERTICAL
  • The frame is created at the specified coordinates relative to its parent (if parentId is provided)