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
X position of the frame
Y position of the frame
Width of the frame
Height of the frame
Basic Properties
Optional name for the frame. Defaults to “Frame” if not provided.
Optional parent node ID to append the frame to. If not provided, the frame is created in the current selection or page.
Fill & Stroke
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 componentg(number, 0-1): Green componentb(number, 0-1): Blue componenta(number, 0-1, optional): Alpha/opacity component
Stroke color in RGBA format. Optional.Properties:
r(number, 0-1): Red componentg(number, 0-1): Green componentb(number, 0-1): Blue componenta(number, 0-1, optional): Alpha/opacity component
Stroke weight (border thickness) in pixels. Must be positive.
Auto-Layout Properties
Auto-layout mode for the frame.Options:
"NONE", "HORIZONTAL", "VERTICAL"Whether the auto-layout frame wraps its children.Options:
"NO_WRAP", "WRAP"Top padding for auto-layout frame in pixels.
Right padding for auto-layout frame in pixels.
Bottom padding for auto-layout frame in pixels.
Left padding for auto-layout frame in pixels.
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.Counter axis alignment for auto-layout frame.Options:
"MIN", "MAX", "CENTER", "BASELINE"Horizontal sizing mode for auto-layout frame.Options:
"FIXED", "HUG", "FILL"Vertical sizing mode for auto-layout frame.Options:
"FIXED", "HUG", "FILL"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 frameid(string): The unique ID of the created frame (use this asparentIdto 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
idasparentIdwhen creating child elements - Colors use RGBA format with values between 0 and 1 (not 0-255)
- When
primaryAxisAlignItemsis set toSPACE_BETWEEN, theitemSpacingproperty is ignored - Auto-layout properties only take effect when
layoutModeis set toHORIZONTALorVERTICAL - The frame is created at the specified coordinates relative to its parent (if
parentIdis provided)