figma-plugin
figma-plugin copied to clipboard
Add support for "full width" property
For dimension or sizing tokens we should offer the ability to impact the width of a layer if it needs to be full width.
Users could set their sizing or dimension tokens to 100%, and if that token is applied to the "Width" property of a layer, we'd try to apply that as "Fill container" (called "Stretch" in the plugin API) in Figma if it's the child of an auto layout parent. If it's a regular layer, we could still look up the parent of the node and use that width as the child width.
Plugin API docs
layoutAlign
Applicable only on direct children of auto-layout frames. Determines if the layer should stretch along the parent’s counter axis. Defaults to “INHERIT”.
Signature
[layoutAlign](https://www.figma.com/plugin-docs/api/properties/nodes-layoutalign/): 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'INHERIT'
Remarks
Changing this property will cause the x, y, size, and relativeTransform properties on this node to change, if applicable (inside an auto-layout frame).
Setting "STRETCH" will make the node "stretch" to fill the width of the parent vertical auto-layout frame, or the height of the parent horizontal auto-layout frame excluding the frame's padding.
If the current node is an auto layout frame (e.g. an auto layout frame inside a parent auto layout frame) if you set layoutAlign to “STRETCH” you should set the corresponding axis – either [primaryAxisSizingMode](https://www.figma.com/plugin-docs/api/properties/nodes-primaryaxissizingmode/) or [counterAxisSizingMode](https://www.figma.com/plugin-docs/api/properties/nodes-counteraxissizingmode/) – to be“FIXED”. This is because an auto-layout frame cannot simultaneously stretch to fill its parent and shrink to hug its children.
Setting "INHERIT" does not "stretch" the node.