Skip to main content
Question

Can I use figma plugin API to do the same thing as "resize to fit" button in panel


shijia.me

image

This topic has been closed for replies.

3 replies

Sonburn
  • New Member
  • 4 replies
  • February 10, 2024

Did you ever find a solution?


tank666
  • 4873 replies
  • February 10, 2024

The easiest way is to turn off the clipsContent, get the absoluteRenderBounds, and then use the resizeWithoutConstraints method and change the coordinates of the children if required.


Johannes_Vollmer1

For anyone coming here, I’ve coded up a solution that worked pretty well for my use case. Some edge cases might not be working yet though. Resizes a parent element around all children, assuming absolute positioning of both.

Github Gist - johannesvollmer / Resize to Fit (Figma Plugin API)


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