UIAPI
Defined in: figmaPluginTypes.ts:2290
https://www.figma.com/plugin-docs/api/figma-ui
onmessage:
undefined|MessageEventHandler
Defined in: figmaPluginTypes.ts:2347
Register a handler for incoming messages from the UI's <iframe> window.
type MessageEventHandler = (
pluginMessage: any,
props: OnMessageProperties
) => void;
interface OnMessageProperties {
origin: string;
}The pluginMessage argument contains the message passed by the call to postMessage on the UI side.
The props argument contains a origin property contains the origin of the document that sent the message. It is an advanced feature, mainly used for implementing OAuth.
close():
void
Defined in: figmaPluginTypes.ts:2310
Destroys the UI and its containing <iframe>. Once this has been called, the code inside the iframe will be stopped and you can no longer send messages to and from it.
void
hide():
void
Defined in: figmaPluginTypes.ts:2298
Hides the current UI. The UI will still continue to run code and be able to send and receive messages. However, it is not rendered to the user.
void
off(
type,callback):void
Defined in: figmaPluginTypes.ts:2365
Removes a handler added via figma.ui.on.
"message"
void
on(
type,callback):void
Defined in: figmaPluginTypes.ts:2357
Register a handler for incoming messages from the UI's <iframe> window.
"message"
void
The pluginMessage argument contains the message passed by the call to postMessage on the UI side.
The props argument contains a origin property contains the origin of the document that sent the message. It is an advanced feature, mainly used for implementing OAuth.
once(
type,callback):void
Defined in: figmaPluginTypes.ts:2361
Register a handler for incoming messages from the UI's <iframe> window. Same as figma.ui.on("message"), but only gets called the first time.
"message"
void
postMessage(
pluginMessage,options?):void
Defined in: figmaPluginTypes.ts:2327
Sends a message to the UI's <iframe> window.
any
This can be almost any data type or plain object, as long as it's a serializable object.
This is similar to saying that it should be possible to send the object over a network if it were necessary. You can send objects, arrays, numbers, strings, booleans, null, undefined, Date objects and Uint8Array objects. However, functions and prototype chains of objects will not be sent.
These restrictions are the same as the browser's postMessage: click here for more details.
An object that may contain the following optional parameters:
origin: An advanced option, mainly used for implementing OAuth. If theoriginoption is provided, the message will only be delivered to the iframe if the origin of the document inside the iframe matches theorigin. This defaults to'*', which allows the message to be passed to any document.
void
Read more about how to use this API in the Creating a User Interface tutorial.
reposition(
x,y):void
Defined in: figmaPluginTypes.ts:2306
Changes the position of the UI, after it has been created. Note that the position can also be set in the initial options.
number
number
void
resize(
width,height):void
Defined in: figmaPluginTypes.ts:2302
Changes the size of the UI, after it has been created. Note that the size can also be set in the initial options. The minimum size is 70x0.
number
number
void
show():
void
Defined in: figmaPluginTypes.ts:2294
Makes the plugin's UI visible. Use this to show the UI if it was created using figma.showUI(..., { visible: false }), or after a call to figma.ui.hide().
void