Skip to main content
shijia.me
Active Member
July 26, 2022
Question

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

  • July 26, 2022
  • 3 replies
  • 647 views

image

This topic has been closed for replies.

3 replies

Sonburn
New Participant
February 10, 2024

Did you ever find a solution?

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

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
Johannes_Vollmer1
October 30, 2024

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)