Skip to main content
shijia.me
Active Member
Jul 26, 2022 9:52 AM UTC
Question

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

image

This topic has been closed for replies.

3 replies

Sonburn
New Participant
Feb 10, 2024 12:29 AM UTC

Did you ever find a solution?

tank666
Feb 10, 2024 10:14 AM UTC

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
Oct 30, 2024 12:00 PM UTC

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)