Layout

With Flexbox, you can specify the layout of an element and its children to provide a consistent layout on different screen sizes.

Setting the Flex Direction establishes the main axis and direction that child elements are placed along in the layout.

Yoga Docs React Native Docs CSS Tricks

Setting align items determines how child elements are spread across the remaining space of the cross axis (the opposite of the axis set in Flex Direction) they lie on.

Yoga Docs React Native Docs CSS Tricks

The Justify Content property determines how children elements are spread across the remaining space of the axis they lie on.

Yoga Docs React Native Docs CSS Tricks

Align Self shares the same positioning behavior as align items, however, it is set on each individual child element and overrides the settings applied to the parent element in Align Items.

Yoga Docs React Native Docs CSS Tricks

The Flex Grow property describes how a child element will automatically resize itself in relation to other child elements within a parent element.

Flex grow can be set to any number greater than 0.

Yoga Docs

Flex Shrink is generally used in tangent with Flex Grow and determines the behavior of children elements once they exceed the size of the container. Just like Flex Grow, Flex Shrink sets a relative value on the children elements. Setting an element's Flex Shrink to 0 prevents the element from shrinking at all and will retain its original size calculated from the Flex Grow setting or from the set width and height.

Flex Shrink can be set to any number greater than 0, with 1 being the default value.

Yoga Docs

Flex basis is an axis-independent way of providing the default size of an item along the main axis. Setting the flex basis of a child is similar to setting the width of that child if its parent is a container with flex direction: row or setting the height of a child if its parent is a container with flex direction: column. The flex basis of an item is the default size of that item, the size of the item before any flex grow and flex shrink calculations are performed.

Flex Shrink can be set to any number greater than 0, with 1 being the default value.

Yoga Documentation

The Flex Wrap property is set on a container and determines how child elements will be laid out if they exceed the maximum dimensions of the container.

Yoga Docs

Align Content is only applicable when children elements are in a container that is set to flex wrap and there are multiple lines of children elements. Setting the Align Content property determines how the lines of elements are positioned on the cross-axis (the axis opposite of the main axis defined in Flex Direction).

Yoga Docs CSS Tricks

Last updated