menu
announcement

Spectrum will become read-only on August 10, 2021. Learn more about the decision in our official announcement.

Channels
Team

Component and instance with resize to auto

February 25, 2020 at 1:05am

Component and instance with resize to auto

February 25, 2020 at 1:05am
Hi, is there any way to set component and instance with 'resize to auto'?
Screen Shot 2020-02-25 at 11.01.56 am (2).png
Thanks again

February 26, 2020 at 7:46pm
Hi, Vivian! Currently Frames, View, Components (and other components that can contains children) automatically resized to their content size by default. If something dynacially changed (through React State, as an example), or something chaged at a code (and rendered after re-launching plugin) this components should resize yourself to new content size. If it's not working in some case that's probable bug. Can you give me more details, please, what case are you trying to solve?
  • reply
  • like

February 27, 2020 at 4:03am
The frame/component/ instance with auto layout children cannot resize properly.
Here is a simple example case below:
<NewComponent.Component>
<View
layoutMode='HORIZONTAL'
horizontalPadding={4}
verticalPadding={1}
style={{
backgroundColor: '#EDF1F5'
}}
>
<Text
characters='testing'
/>
</View>
</NewComponent.Component>
Edited
  • reply
  • like

February 27, 2020 at 8:03pm
Currently horizontalPadding/verticalPadding not used for calculating layout (through yoga-layout lib), so frame and component just get width/height equal to text (37x14). I will fix it.
like-fill
1
  • reply
  • like

February 28, 2020 at 3:30pm
Also, it's possible to write something like this (without Figma auto-layout):
<NewComponent.Component>
<View
style={{
backgroundColor: '#EDF1F5',
paddingTop: 1,
paddingBottom: 1,
paddingLeft: 4,
paddingRight: 4
}}
>
<Text>
testing
</Text>
</View>
</NewComponent.Component>
Edited
  • reply
  • like

March 10, 2020 at 7:05pm
Great news! The issue fixed at [email protected].
  • reply
  • like