Skip to main content

WidgetNode

Represents a widget node in FigJam. To learn more about FigJam Widgets, visit our widget documentation.

Widget properties

type: 'WIDGET' [readonly]

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


widgetId: string [readonly]

The value specified in widget's manifest.json "id" field.

If this WidgetNode was created by your widget WidgetNode.widgetId will match figma.widgetId. This is useful when managing multiple widget nodes that belong to the same widgetId.


widgetSyncedState: { [key: string]: any } [readonly]

Returns the synced state stored on the widget. This is only readable by widgets created by the same manifest.id.

For more information, check out this page in our widget documentation.


clone(): WidgetNode

Create an identical copy of this WidgetNode. By default, the duplicate will be parented under figma.currentPage.


cloneWidget(syncedStateOverrides: { [name: string]: any }, syncedMapOverrides?: { [mapName: string]: { [key: string]: any } }): WidgetNode

Create a copy of this WidgetNode while overriding specific synced state & synced map values for the widget. Overrides are only applied if a widget is cloning itself or other widgets created by the same manifest.id.

View more →

setWidgetSyncedState(syncedState: { [name: string]: any }, syncedMap?: { [mapName: string]: { [key: string]: any } }): void

Sets the entire synced state and synced map values for a widget. This function only sets the synced state for widgets with a matching node.widgetId (an instance of the same widget). This means that running this function only works inside of a widget.

View more →

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.

View 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.

View 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).

View 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.

View 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.

View more →

remove(): void

Removes this node and all of its children from the document.

View 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 {}.

info

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

View 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.

View 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.

View 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.


x: number

The position of the node. Identical to relativeTransform[0][2].

View more →

y: number

The position of the node. Identical to relativeTransform[1][2].

View more →

width: number [readonly]

The width of the node. Use a resizing method to change this value.


height: number [readonly]

The height of the node. Use a resizing method to change this value.


relativeTransform: Transform

The position of a node relative to its containing parent as a Transform matrix. Not used for scaling, see width and height instead. Read the details page to understand the nuances of this property.

View more →

absoluteTransform: Transform [readonly]

The position of a node relative to its containing page as a Transform matrix.


Scene node properties

visible: boolean

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

View 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.

View more →

stuckNodes: SceneNode[] [readonly]

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.

View more →

attachedConnectors: ConnectorNode[] [readonly]

An array of ConnectorNodes that are attached to a node.


componentPropertyReferences: { [nodeProperty in 'visible' | 'characters' | 'mainComponent']: string } | null

All component properties that are attached on this node. A node can only have componentPropertyReferences if it is a component sublayer and is not nested within an instance node. Is null otherwise. The value in the key-value pair refers to the component property name as returned by componentPropertyDefinitions on the containing component or component set.


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.

View more →

Stickable properties

In FigJam a stickable is any node that sticks to other nodes when put on top of them. If the node the stickable is stuckTo moves, the stickable moves along with it.

stuckTo: SceneNode | null

If this node is stuck to another node this property returns that node or null.

View more →