Figma Plugins

Figma Plugins

  • Introduction
  • API Reference
  • Updates

›Node APIs

Figma APIs

  • API Reference
  • The Typings File
  • figma
  • figma.ui
  • figma.timer
  • figma.viewport
  • figma.clientStorage
  • figma.parameters
  • API errors

Node APIs

  • Node Types
  • BooleanOperationNode
  • CodeBlockNode
  • ComponentNode
  • ComponentSetNode
  • ConnectorNode
  • DocumentNode
  • EllipseNode
  • EmbedNode
  • FrameNode
  • GroupNode
  • HighlightNode
  • InstanceNode
  • LineNode
  • LinkUnfurlNode
  • MediaNode
  • PageNode
  • PolygonNode
  • RectangleNode
  • SectionNode
  • ShapeWithTextNode
  • SliceNode
  • StampNode
  • StarNode
  • StickyNode
  • TextNode
  • VectorNode
  • WashiTapeNode
  • WidgetNode

Data Types

  • Action
  • ActiveUser
  • ArcData
  • BlendMode
  • ConnectorEndpoint
  • ConnectorStrokeCap
  • Constraints
  • Effect
  • EmbedData
  • ExportSettings
  • FontName
  • Guide
  • HandleMirroring
  • HyperlinkTarget
  • Image
  • LabelSublayer
  • LayoutGrid
  • LetterSpacing
  • LineHeight
  • LinkUnfurlData
  • MediaData
  • OverflowDirection
  • Overlay
  • Paint
  • PublishStatus
  • Reaction
  • Rect
  • RGB/RGBA
  • StrokeCap
  • StrokeJoin
  • StyledTextSegment
  • TextCase
  • TextDecoration
  • TextSublayer
  • Transition
  • Transform
  • Trigger
  • User
  • Vector
  • VectorPath
  • VectorNetwork
  • BaseStyle
  • EffectStyle
  • GridStyle
  • PaintStyle
  • TextStyle

Properties

  • findAll
  • findAllWithCriteria
  • findChild
  • findChildren
  • findOne
  • constraint
  • svgOutlineText
  • scaleFactor
  • swapComponent
  • resize
  • resizeWithoutConstraints
  • flowStartingPoints
  • guides
  • selectedTextRange
  • selection
  • resizeWithoutConstraints
  • rescale
  • resize
  • autoRename
  • characters
  • deleteCharacters
  • getStyledTextSegments
  • insertCharacters
  • textAutoResize
  • data
  • windingRule
  • cloneWidget
  • setWidgetSyncedState
  • closePlugin
  • combineAsVariants
  • commitUndo
  • createBooleanOperation
  • createComponent
  • createConnector
  • createEllipse
  • createFrame
  • createGif
  • createImage
  • createLine
  • createLinkPreviewAsync
  • createPage
  • createPolygon
  • createRectangle
  • createShapeWithText
  • createSlice
  • createStar
  • createSticky
  • createText
  • createVector
  • flatten
  • group
  • loadFontAsync
  • mixed
  • notify
  • off
  • on
  • saveVersionHistoryAsync
  • showUI
  • skipInvisibleInstanceChildren
  • on
  • onmessage
  • postMessage
  • zoom
  • appendChild
  • children
  • constraints
  • cornerRadius
  • cornerSmoothing
  • counterAxisAlignItems
  • counterAxisSizingMode
  • description
  • documentationLinks
  • exportAsync
  • fills
  • fillStyleId
  • findAll
  • findAllWithCriteria
  • findChild
  • findChildren
  • findOne
  • findWidgetNodesByWidgetId
  • id
  • insertChild
  • layoutAlign
  • layoutGrow
  • layoutMode
  • locked
  • name
  • numberOfFixedChildren
  • overflowDirection
  • parent
  • primaryAxisAlignItems
  • primaryAxisSizingMode
  • relativeTransform
  • remove
  • removed
  • rescale
  • resize
  • resizeWithoutConstraints
  • rotation
  • setPluginData
  • setRelaunchData
  • setSharedPluginData
  • strokeAlign
  • strokeCap
  • strokeJoin
  • stuckNodes
  • stuckTo
  • toString
  • visible
  • x
  • y

PageNode

The page node is always a descendent of the DocumentNode. Most plugins only need to access the current page accessed via figma.currentPage.

Page properties

type: 'PAGE' [readonly]

The type of this node, represented by the string literal "PAGE"

clone(): PageNode

Create a clone of this page, parented under figma.root. Prototyping connections will be copied such that they point to their equivalent in the cloned page. Components will be cloned as instances who master is the original component.

guides: ReadonlyArray<Guide>

The guides on this page. [Read more]

selection: ReadonlyArray<SceneNode>

The selected nodes on this page. Each page stores its own selection separately. The ordering of nodes in the selection is unspecified, you should not be relying on it. [Read more]

selectedTextRange: { node: TextNode; start: number; end: number } | null

The current text node being edited, if any, and the text currently being selected within that text node. [Read more]

flowStartingPoints: ReadonlyArray<{ nodeId: string; name: string }>

The sorted list of flow starting points used when accessing Presentation view. [Read more]

backgrounds: ReadonlyArray<Paint>

The background color of the canvas (currently only supports a single solid color paint).

prototypeBackgrounds: ReadonlyArray<Paint>

The background color of the prototype (currently only supports a single solid color paint).

prototypeStartNode: FrameNode | GroupNode | ComponentNode | InstanceNode | null [readonly]

The starting point when launching a prototype. Prototypes with a starting node contain all frames reachable from that node. Prototypes without a starting node contain all frames on the current page. Note that prototypes are per-page.

Base node properties

id: string [readonly]

An internal identifier for a node. Plugins typically don't need to use this since you can usually just access a node directly. [Read more]

parent: (BaseNode & ChildrenMixin) | null [readonly]

Returns the parent of this node, if any. This property is not meant to be directly edited. To reparent, see appendChild. [Read more]

name: string

The name of the layer that appears in the layers panel. This may update automatically for text layers. Returns the name of the current file on figma.root (read-only). [Read more]

removed: boolean [readonly]

Returns true if this node has been removed since it was first accessed. If your plugin stays open for a while and stores references to nodes, you should write your code defensively and check that the nodes haven't been removed by the user. [Read more]

toString(): string

Returns a string representation of the node. For debugging purposes only, do not rely on the exact output of this string in production code. [Read more]

remove(): void

Removes this node and all of its children from the document. [Read more]

setRelaunchData(data: { [command: string]: string }): void

Sets state on the node to show a button and description when the node is selected. Clears the button and description when relaunchData is {}.

In Figma, this shows up in the properties panel. In FigJam, this shows up in the property menu. See here for examples. [Read more]

getRelaunchData(): { [command: string]: string }

Retreives the reluanch data stored on this node using setRelaunchData

getPluginData(key: string): string

Retrieves custom information that was stored on this node or style using setPluginData. If there is no data stored for the provided key, an empty string is returned.

setPluginData(key: string, value: string): void

Lets you store custom information on any node or style, private to your plugin. [Read more]

getPluginDataKeys(): string[]

Retrieves a list of all keys stored on this node or style using using setPluginData. This enables iterating through all data stored privately on a node or style by your plugin.

getSharedPluginData(namespace: string, key: string): string

Retrieves custom information that was stored on this node or style using setSharedPluginData. If there is no data stored for the provided namespace and key, an empty string is returned.

setSharedPluginData(namespace: string, key: string, value: string): void

Lets you store custom information on any node or style, public to all plugins. [Read more]

getSharedPluginDataKeys(namespace: string): string[]

Retrieves a list of all keys stored on this node or style using setSharedPluginData. This enables iterating through all data stored in a given namespace.

Scene node properties

visible: boolean

Whether the node is visible or not. Does not affect a plugin's ability to access the node. [Read more]

locked: boolean

Whether the node is locked or not, preventing certain user interactions on the canvas such as selecting and dragging. Does not affect a plugin's ability to write to those properties. [Read more]

stuckNodes: SceneNode[]

An array of nodes that are "stuck" to this node. In FigJam, stamps, highlights, and some widgets can "stick" to other nodes if they are dragged on top of another node. [Read more]

Children-related properties

children: ReadonlyArray<SceneNode> [readonly]

The list of children, sorted back-to-front. That is, the first child in the array is the bottommost layer on the screen, and the last child in the array is the topmost layer. [Read more]

appendChild(child: SceneNode): void

Adds a new child to the end of the children array. That is, visually on top of all other children. [Read more]

insertChild(index: number, child: SceneNode): void

Adds a new child at the specified index in the children array. [Read more]

findChildren(callback?: (node: SceneNode) => boolean): SceneNode[]

Searches the immediate children of this node (i.e. not including the children's children). Returns all nodes for which callback returns true. [Read more]

findChild(callback: (node: SceneNode) => boolean): SceneNode | null

Searches the immediate children of this node (i.e. not including the children's children). Returns the first node for which callback returns true. [Read more]

findAll(callback?: (node: SceneNode) => boolean): SceneNode[]

Searches this entire subtree (this node's children, its children's children, etc). Returns all nodes for which callback returns true. [Read more]

findOne(callback: (node: SceneNode) => boolean): SceneNode | null

Searches this entire subtree (this node's children, its children's children, etc). Returns the first node for which callback returns true. [Read more]

findAllWithCriteria<T extends NodeType[]>(criteria: { types: T }): Array<{ type: T[number] } & SceneNode>

Searches this entire subtree (this node's children, its children's children, etc). Returns all nodes that satisfy any of the types defined in the criteria. [Read more]

findWidgetNodesByWidgetId(widgetId: string): Array<WidgetNode>

Searches this entire subtree (this node's children, its children's children, etc). Returns all widget nodes that match the provided widgetId. [Read more]

Export-related properties

exportSettings: ReadonlyArray<ExportSettings>

List of export settings stored on the node. For help on how to change this value, see Editing Properties.

exportAsync(settings?: ExportSettings): Promise<Uint8Array>

Exports the node as an encoded image. [Read more]

← MediaNodePolygonNode →
  • Page properties
  • Base node properties
  • Scene node properties
  • Children-related properties
  • Export-related properties
Learn more about Figma