2018-02-13 03:50:31 -08:00
|
|
|
|
---
|
2018-02-19 02:55:30 -08:00
|
|
|
|
path: "/docs/flex"
|
2018-02-13 03:50:31 -08:00
|
|
|
|
title: "Flex Basis, Grow, and Shrink"
|
|
|
|
|
hasPlayground: true
|
|
|
|
|
---
|
|
|
|
|
|
2018-02-13 06:37:40 -08:00
|
|
|
|
## Flex Basis, Grow, and Shrink
|
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
|
**FLEX GROW** describes how any space within a container should be distributed
|
2018-02-13 06:37:40 -08:00
|
|
|
|
among its children along the main axis. After laying out its children, a container will
|
|
|
|
|
distribute any remaining space according to the flex grow values specified by its children.
|
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
|
Flex grow accepts any floating point value >= 0, with 0 being the default value.
|
2018-02-13 06:37:40 -08:00
|
|
|
|
A container will distribute any remaining space among its children weighted by the child’s flex grow value.
|
|
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
|
<controls prop="flexGrow"></controls>
|
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
|
**FLEX SHRINK** describes how to shrink children along the main axis in the
|
2018-02-13 06:37:40 -08:00
|
|
|
|
case that the total size of the children overflow the size of the container on the main axis.
|
|
|
|
|
flex shrink is very similar to flex grow and can be thought of in the same way if
|
|
|
|
|
any overflowing size is considered to be negative remaining space.
|
|
|
|
|
These two properties also work well together by allowing children to grow and shrink as needed.
|
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
|
Flex shrink accepts any floating point value >= 0, with 1 being the default value.
|
2018-02-13 06:37:40 -08:00
|
|
|
|
A container will shrink its children weighted by the child’s flex shrink value.
|
|
|
|
|
|
2018-02-14 07:53:07 -08:00
|
|
|
|
<controls prop="flexShrink"></controls>
|
|
|
|
|
|
2018-02-14 08:42:49 -08:00
|
|
|
|
**FLEX BASIS** is an axis-independent way of providing the default size of an item
|
2018-02-16 06:41:54 -08:00
|
|
|
|
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
|
2018-02-13 06:37:40 -08:00
|
|
|
|
calculations are performed.
|
2018-02-14 07:53:07 -08:00
|
|
|
|
|
|
|
|
|
<controls prop="flexBasis"></controls>
|