Skip to main content
Solved

Center align plugin container

  • September 2, 2021
  • 4 replies
  • 1372 views

Chethan_Jagannatha_Kulkarni

How can I center align the plugin container, based on screen size?

Best answer by tank666

With the recent update to the Plugin API, this is now possible.

Code.js example:

let pluginWidth = 800,
	pluginHeight = 480,
	centerX = Math.round(figma.viewport.center.x - (pluginWidth / 2)),
	centerY = Math.round(figma.viewport.center.y - (pluginHeight / 2));

figma.showUI(
	__html__,
	{
		title: 'Plugin Name',
		width: pluginWidth,
		height: pluginHeight,
		position: {
			x: centerX,
			y: centerY
		}
	}
);
View original
This topic has been closed for replies.

4 replies

Gleb
  • Power Member
  • 4708 replies
  • September 2, 2021

There is no way to move it, unfortunately. Only the user can control where the plugin window is placed.


Chethan_Jagannatha_Kulkarni

Thanks 👍


tank666
  • 4873 replies
  • September 2, 2021

You can vote for a similar idea here: Handle plugin location from figma.ui


tank666
  • 4873 replies
  • Answer
  • October 12, 2021

With the recent update to the Plugin API, this is now possible.

Code.js example:

let pluginWidth = 800,
	pluginHeight = 480,
	centerX = Math.round(figma.viewport.center.x - (pluginWidth / 2)),
	centerY = Math.round(figma.viewport.center.y - (pluginHeight / 2));

figma.showUI(
	__html__,
	{
		title: 'Plugin Name',
		width: pluginWidth,
		height: pluginHeight,
		position: {
			x: centerX,
			y: centerY
		}
	}
);

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