Complete the code to create a component instance from a main component named 'Button'.
const buttonInstance = figma.currentPage.create[1](); buttonInstance.mainComponent = figma.root.findOne(n => n.name === 'Button');
In Figma, to create an instance of a component, you use createInstance(). The instance is of type Instance.
Complete the code to set the position of a component instance to x=100 and y=200.
buttonInstance.x = [1]; buttonInstance.y = 200;
The x property sets the horizontal position. To place it at 100, assign buttonInstance.x = 100;.
Fix the error in the code to properly detach a component instance from its main component.
buttonInstance.[1]();To detach an instance from its main component in Figma, use the detachInstance() method.
Fill both blanks to change the text content of a text node inside a component instance.
const textNode = buttonInstance.findOne(n => n.type === [1]); textNode.characters = [2];
The type of a text node is TEXT. To change its content, assign a string like 'Click me' to characters.
Fill all three blanks to create a new instance, set its position, and add it to the current page.
const newInstance = figma.currentPage.[1](); newInstance.mainComponent = figma.root.findOne(n => n.name === [2]); newInstance.[3] = 50;
Use createInstance() to make a new instance. Set its main component by name, e.g., 'Icon'. Then set its x position to 50.