Styling
Each Yoga node has an associated style. Nodes may be styled using similar properties to CSS, with some caveats.
Default styles
The default Yoga node style is similar to a box on web set to display: flex
, with a few notable exceptions:
flex-direction
defaults tocolumn
instead ofrow
align-content
defaults toflex-start
instead ofstretch
flex-shrink
defaults to0
instead of1
position
defaults torelative
instead ofstatic
Yoga may be configured to align to the defaults on web for flex-direction
, align-content
, and flex-shrink
by setting the UseWebDefaults
flag.
Because UseWebDefaults
was established before the introduction of position: 'static'
, it does not change the default position
, in order to preserve compatibility.
Box Sizing
Yoga acts as if box-sizing: 'border-box'
is set. This means that specified dimensions for a box will include the space taken for padding and border.
Edges
Margin, padding, position, and border, are set against an Edge, which may be:
- Relative to writing direction (start/end)
- A physical edge (top/right/left/bottom)
- A collection of edges (vertical/horizontal/all)
A style value may be set against multiple Edge values at once, with precedence given in the above order.
Units
Yoga does not operate on CSS units like px
or em
. Yoga instead works on "points", representing an arbitrary, canonical absolute unit (usually mapped to display independent pixels), along with percentage. Other units should be absolutized before being given to Yoga.
Non-standard properties
Yoga's aspect-ratio
property was added before the same property was added to CSS, and may act subtlety different. These differences may be reconciled in a future version of Yoga.
Yoga's flex
shorthand will act as flex-grow
if positive, or flex-shrink
if negative.