Based on the provided search results, there isn't specific information about making a Figma plugin's UI height automatically adjust to its content. The search results primarily focus on auto-layout and resizing behaviors within Figma designs themselves rather than plugin UI development.
However, I can provide some guidance on this topic: In Figma plugin development, the plugin UI (which runs in an iframe) doesn't automatically "hug" content like auto-layout frames do within Figma designs. You'll need to programmatically manage the plugin's dimensions.
Manual Resize Method
You can calculate your content height and resize the plugin window accordingly using the figma.ui.resize()
method:
// In your plugin's main code
figma.ui.resize(width, calculatedHeight);
Content Height Calculation In your plugin's HTML/CSS, you can calculate the content height and send it to the main plugin code:
// In your UI code (HTML file)
function adjustPluginHeight() {
const contentHeight = document.body.scrollHeight;
parent.postMessage({
pluginMessage: {
type: 'resize',
height: contentHeight
}
}, '*');
}
// Listen for content changes
window.addEventListener('load', adjustPluginHeight);
Dynamic Content Updates For content that changes dynamically, you'll need to recalculate and resize whenever content is added or removed.
Unlike Figma's auto-layout "hug content" feature that works automatically within designs[4][5], plugin UIs require manual height management through the plugin API.
[1] https://forum.figma.com/archive-21/hug-content-in-auto-layout-frame-via-plugin-api-28817 [2] https://www.captain-design.com/blog/figma-responsive-auto-layout-using-the-resizing-feature/ [3] https://forum.figma.com/archive-21/dynamic-frame-height-33308 [4] https://www.reddit.com/r/FigmaDesign/comments/16ssmya/can_i_make_a_variable_of_fixed_height_hug/ [5] https://designcode.io/figma-handbook-hug-content-resizing/ [6] https://forum.figma.com/ask-the-community-7/issue-applying-max-width-and-max-height-properties-for-text-layers-in-auto-layout-using-plugin-api-21489 [7] https://icinga.com/blog/figmas-powerful-autolayout-feature/ [8] https://forum.figma.com/ask-the-community-7/help-auto-resize-component-based-on-text-length-23035 [9] https://forum.figma.com/suggest-a-feature-11/set-grid-row-height-to-hug-contents-40435 [10] https://forum.figma.com/report-a-problem-6/figma-applies-the-hugh-content-to-the-width-and-height-but-i-only-want-to-apply-it-to-the-width-29035