Skip to main content
Solved

How to set constraints for a layer?

  • January 12, 2022
  • 1 reply
  • 759 views

Tuan_Au

Hi I want to set constraints for a Text Node but it seems like the property is read-only Constraints · Figma Developers
Also, I don’t find any method or way to set the constraints.
How can I do it?
Thank you,

Best answer by tank666

To change read-only properties, you need to overwrite the entire object or array. In your case, you need to overwrite the object, and the code will look like this:

node.constraints = {
	horizontal: "MAX",
	vertical: "MAX"
}

Read more about editing properties on the Figma Developers:

figma.com
View original

1 reply

tank666
  • 4863 replies
  • Answer
  • January 12, 2022

To change read-only properties, you need to overwrite the entire object or array. In your case, you need to overwrite the object, and the code will look like this:

node.constraints = {
	horizontal: "MAX",
	vertical: "MAX"
}

Read more about editing properties on the Figma Developers:

figma.com

Reply


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