Skip to main content
Question

Way to dynamically size plugin window based on browser window?


hjj

Is there a way to dynamically size the plugin window based on browser window?
Looking for a height and width to plug into

figma.showUI(___html___, {height, width})

Methods tried:

  • document.documentElement.clientWidth (document is not defined)
  • parent.document.body.clientWidth (parent is not defined)
  • window.outerWidth (window is not defined)
  • figma.viewport dimensions do not correspond to browser window dimensions.

3 replies

Gleb
  • Power Member
  • 4708 replies
  • July 20, 2022

You tried these methods on the plugins backend side, but you need to do it on the UI side.


hjj
  • Author
  • 1 reply
  • July 21, 2022

Hey, thanks for looking. Can you please elaborate? When I try to access the figma object from within the React app, I get this error:
ReferenceError: figma is not defined


Gleb
  • Power Member
  • 4708 replies
  • July 21, 2022

None of the methods you mentioned except the last one needs figma.

You can’t access figma object in the UI. UI is for all the browser APIs, backend is for interacting with figma. See this post on how to communicate between the two environments: Creating a User Interface | Plugin API


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings