2018-02-13 03:50:31 -08:00
|
|
|
---
|
2018-02-19 02:55:30 -08:00
|
|
|
path: "/docs/margins-paddings-borders"
|
2018-02-13 03:50:31 -08:00
|
|
|
title: "Margins, Paddings, and Borders"
|
|
|
|
hasPlayground: true
|
|
|
|
---
|
|
|
|
|
2018-02-13 06:37:42 -08:00
|
|
|
## Margins, Paddings, and Borders
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
**MARGIN** effects the spacing around the outside of a node. A node with margin
|
2018-02-13 06:37:42 -08:00
|
|
|
will offset itself from the bounds of its parent but also offset the
|
|
|
|
location of any siblings. The margin of a node contributes to the total size
|
|
|
|
of its parent if the parent is auto sized.
|
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
<controls prop="margin"></controls>
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
**PADDING** affects the size of the node it is applied to. Padding in Yoga acts as if
|
2018-02-13 06:37:42 -08:00
|
|
|
`box-sizing: border-box;` was set. That is padding will not add to the total size
|
|
|
|
of an element if it has an explicit size set. For auto sized nodes padding will increase
|
|
|
|
the size of the node as well as offset the location of any children.
|
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
<controls prop="padding"></controls>
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
**BORDER** in Yoga acts exactly like padding and only exists as a seperate property so
|
2018-02-13 06:37:42 -08:00
|
|
|
that higher level frameworks get a hint as to how thick to draw a border. Yoga however
|
|
|
|
does not do any drawing so just uses this information during layout where border
|
|
|
|
acts exactly like padding.
|
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
<controls prop="border"></controls>
|