2024-03-08 14:13:55 -08:00
|
|
|
---
|
|
|
|
sidebar_position: 14
|
|
|
|
---
|
|
|
|
|
2024-03-12 11:31:46 -07:00
|
|
|
import Playground from '@site/src/components/Playground';
|
|
|
|
|
2024-03-08 14:13:55 -08:00
|
|
|
# Width and Height
|
2024-03-12 11:31:46 -07:00
|
|
|
|
2024-03-13 10:19:30 -07:00
|
|
|
The width property specifies the width of the node's border box (the collective size of the node's content, padding, and border).
|
|
|
|
Similarly height property specifies the height of the node's border box.
|
2024-03-12 11:31:46 -07:00
|
|
|
|
2024-03-13 10:19:30 -07:00
|
|
|
Both width and height can take following values:
|
2024-03-12 11:31:46 -07:00
|
|
|
|
|
|
|
**Auto**: The default Value, Yoga calculates the width/height for the node based
|
|
|
|
on its content, whether that is other children, text, or an image.
|
|
|
|
|
|
|
|
**Pixels**: Defines the width/height in absolute pixels. Depending on other properties set on
|
|
|
|
the Yoga node this may or may not be the final dimension of the node.
|
|
|
|
|
2024-03-13 10:19:30 -07:00
|
|
|
**Percentage**: Defines the width or height in percentage of its [containing block's](/docs/advanced/containing-block) width or height respectively.
|
2024-03-12 11:31:46 -07:00
|
|
|
|
|
|
|
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
|
|
|
<Node
|
|
|
|
style={{
|
|
|
|
width: 200,
|
|
|
|
height: 200,
|
2024-03-13 10:19:30 -07:00
|
|
|
padding: 10,
|
2024-03-12 11:31:46 -07:00
|
|
|
}}>
|
|
|
|
<Node
|
|
|
|
style={{
|
|
|
|
margin: 5,
|
|
|
|
height: 50,
|
|
|
|
width: 50,
|
2024-03-13 10:19:30 -07:00
|
|
|
}}
|
|
|
|
/>
|
2024-03-12 11:31:46 -07:00
|
|
|
</Node>
|
|
|
|
</Layout>`} />
|