Skip to content

Commit 5b4df51

Browse files
kyarikespipj
authored andcommitted
Fixes to Layout with Flexbox
1 parent d0946a7 commit 5b4df51

1 file changed

Lines changed: 33 additions & 33 deletions

File tree

docs/flexbox.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ You will normally use a combination of `flexDirection`, `alignItems`, and `justi
1313

1414
[`flex`](https://facebook.github.io/react-native/docs/layout-props#flex) will define how your items are going to **“fill”** over the available space along your main axis. Space will be divided according to each element's flex property.
1515

16-
In the following example the red, yellow and the green views are all children in the container view that has `flex: 1` set. The red view uses `flex: 1` , the yellow view uses `flex: 2` and the green view uses `flex: 3` . **1+2+3 = 6** which means that the red view will get `1/6` of the space, the yellow `2/6` of the space and the green `3/6` of the space.
16+
In the following example, the red, yellow, and green views are all children in the container view that has `flex: 1` set. The red view uses `flex: 1` , the yellow view uses `flex: 2`, and the green view uses `flex: 3` . **1+2+3 = 6**, which means that the red view will get `1/6` of the space, the yellow `2/6` of the space, and the green `3/6` of the space.
1717

1818
![Flex](https://cdn-images-1.medium.com/max/800/1*PhCFmO5tYX_sZSyCd4vO3w.png)
1919

2020
#### Flex Direction
2121

2222
[`flexDirection`](https://facebook.github.io/react-native/docs/layout-props#flexdirection) controls the direction in which the children of a node are laid out. This is also referred to as the _main axis_. The cross axis is the axis perpendicular to the main axis, or the axis which the wrapping lines are laid out in.
2323

24-
- `row` Align children from left to right. If wrapping is enabled then the next line will start under the first item on the left of the container.
24+
- `row` Align children from left to right. If wrapping is enabled, then the next line will start under the first item on the left of the container.
2525

26-
- `column` (**default value**) Align children from top to bottom. If wrapping is enabled then the next line will start to the left first item on the top of the container.
26+
- `column` (**default value**) Align children from top to bottom. If wrapping is enabled, then the next line will start to the left first item on the top of the container.
2727

28-
- `row-reverse` Align children from right to left. If wrapping is enabled then the next line will start under the first item on the right of the container.
28+
- `row-reverse` Align children from right to left. If wrapping is enabled, then the next line will start under the first item on the right of the container.
2929

30-
- `column-reverse` Align children from bottom to top. If wrapping is enabled then the next line will start to the left first item on the bottom of the container.
30+
- `column-reverse` Align children from bottom to top. If wrapping is enabled, then the next line will start to the left first item on the bottom of the container.
3131

32-
LEARN MORE [HERE](https://yogalayout.com/docs/flex-direction)
32+
You can learn more [here](https://yogalayout.com/docs/flex-direction).
3333

3434
```SnackPlayer name=Flex%20Direction
3535
import React, { Component } from 'react';
@@ -53,11 +53,11 @@ export default class FlexDirectionBasics extends Component {
5353

5454
### Layout Direction
5555

56-
Layout direction specifies the direction in which children and text in a hierarchy should be laid out. Layout direction also affects what edge `start` and `end` refer to. By default React Native lays out with LTR layout direction. In this mode `start` refers to left and `end` refers to right.
56+
Layout direction specifies the direction in which children and text in a hierarchy should be laid out. Layout direction also affects what edge `start` and `end` refer to. By default, React Native lays out with LTR layout direction. In this mode `start` refers to left and `end` refers to right.
5757

58-
- `LTR` (**default value**) Text and children are laid out from left to right. Margin and padding applied the start of an element are applied on the left side.
58+
- `LTR` (**default value**) Text and children are laid out from left to right. Margin and padding applied to the start of an element are applied on the left side.
5959

60-
- `RTL` Text and children are laid out from right to left. Margin and padding applied the start of an element are applied on the right side.
60+
- `RTL` Text and children are laid out from right to left. Margin and padding applied to the start of an element are applied on the right side.
6161

6262
#### Justify Content
6363

@@ -69,13 +69,13 @@ Layout direction specifies the direction in which children and text in a hierarc
6969

7070
- `center` Align children of a container in the center of the container's main axis.
7171

72-
- `space-between` Evenly space of children across the container's main axis, distributing remaining space between the children.
72+
- `space-between` Evenly space off children across the container's main axis, distributing the remaining space between the children.
7373

74-
- `space-around` Evenly space of children across the container's main axis, distributing remaining space around the children. Compared to `space-between` using `space-around` will result in space being distributed to the beginning of the first child and end of the last child.
74+
- `space-around` Evenly space off children across the container's main axis, distributing the remaining space around the children. Compared to `space-between`, using `space-around` will result in space being distributed to the beginning of the first child and end of the last child.
7575

76-
- `space-evenly` Evenly distributed within the alignment container along the main axis. The spacing between each pair of adjacent items, the main-start edge and the first item, and the main-end edge and the last item, are all exactly the same.
76+
- `space-evenly` Evenly distribute children within the alignment container along the main axis. The spacing between each pair of adjacent items, the main-start edge and the first item, and the main-end edge and the last item, are all exactly the same.
7777

78-
LEARN MORE [HERE](https://yogalayout.com/docs/justify-content)
78+
You can learn more [here](https://yogalayout.com/docs/justify-content).
7979

8080
```SnackPlayer name=Justify%20Content
8181
import React, { Component } from 'react';
@@ -118,7 +118,7 @@ export default class JustifyContentBasics extends Component {
118118

119119
> For `stretch` to have an effect, children must not have a fixed dimension along the secondary axis. In the following example, setting `alignItems: stretch` does nothing until the `width: 50` is removed from the children.
120120
121-
LEARN MORE [HERE](https://yogalayout.com/docs/align-items)
121+
You can learn more [here](https://yogalayout.com/docs/align-items).
122122

123123
```SnackPlayer name=Align%20Items
124124
import React, { Component } from 'react';
@@ -161,59 +161,59 @@ export default class AlignItemsBasics extends Component {
161161

162162
- `flex-end` Align wrapped lines to the end of the container's cross axis.
163163

164-
- `stretch` wrapped lines to match the height of the container's cross axis.
164+
- `stretch` Stretch wrapped lines to match the height of the container's cross axis.
165165

166166
- `center` Align wrapped lines in the center of the container's cross axis.
167167

168-
- `space-between` Evenly space wrapped lines across the container's main axis, distributing remaining space between the lines.
168+
- `space-between` Evenly space wrapped lines across the container's main axis, distributing the remaining space between the lines.
169169

170-
- `space-around` Evenly space wrapped lines across the container's main axis, distributing remaining space around the lines. Compared to space between using space around will result in space being distributed to the begining of the first lines and end of the last line.
170+
- `space-around` Evenly space wrapped lines across the container's main axis, distributing the remaining space around the lines. Compared to `space-between`, using `space-around` will result in space being distributed to the begining of the first lines and end of the last line.
171171

172-
LEARN MORE [HERE](https://yogalayout.com/docs/align-content)
172+
You can learn more [here](https://yogalayout.com/docs/align-content).
173173

174174
![Align Content](https://cdn-images-1.medium.com/max/800/1*cC2XFyCF_igp20Ombt4wBw.png)
175175

176176
### Flex Wrap
177177

178-
The [`flexWrap`](https://facebook.github.io/react-native/docs/layout-props#flexwrap) property is set on containers and controls what happens when children overflow the size of the container along the main axis. By default children are forced into a single line (which can shrink elements). If wrapping is allowed items are wrapped into multiple lines along the main axis if needed.
178+
The [`flexWrap`](https://facebook.github.io/react-native/docs/layout-props#flexwrap) property is set on containers and it controls what happens when children overflow the size of the container along the main axis. By default, children are forced into a single line (which can shrink elements). If wrapping is allowed, items are wrapped into multiple lines along the main axis if needed.
179179

180-
When wrapping lines `alignContent` can be used to specify how the lines are placed in the container. learn more [here](https://yogalayout.com/docs/flex-wrap)
180+
When wrapping lines, `alignContent` can be used to specify how the lines are placed in the container. Learn more [here](https://yogalayout.com/docs/flex-wrap).
181181

182182
![Flex Wrap](https://cdn-images-1.medium.com/max/800/1*_7v4uQhSsuCn1cfeOMVfrA.png)
183183

184184
### Flex Basis, Grow, and Shrink
185185

186186
- [`flexGrow`](https://facebook.github.io/react-native/docs/layout-props#flexgrow) describes how any space within a container should be distributed 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.
187187

188-
flexGrow accepts any floating point value >= 0, with 0 being the default value. A container will distribute any remaining space among its children weighted by the child’s flex grow value.
188+
`flexGrow` accepts any floating point value >= 0, with 0 being the default value. A container will distribute any remaining space among its children weighted by the children’s `flexGrow` values.
189189

190-
- [`flexShrink`](https://facebook.github.io/react-native/docs/layout-props#flexshrink) describes how to shrink children along the main axis in the 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.
190+
- [`flexShrink`](https://facebook.github.io/react-native/docs/layout-props#flexshrink) describes how to shrink children along the main axis in the case in which the total size of the children overflows the size of the container on the main axis. `flexShrink` is very similar to `flexGrow` 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.
191191

192-
Flex shrink accepts any floating point value >= 0, with 1 being the default value. A container will shrink its children weighted by the child’s flex shrink value.
192+
`flexShrink` accepts any floating point value >= 0, with 1 being the default value. A container will shrink its children weighted by the children’s `flexShrink` values.
193193

194-
- [`flexBasis`](https://facebook.github.io/react-native/docs/layout-props#flexbasis) 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 `flexDirection: row` or setting the `height` of a child if its parent is a container with `flexDirection: 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.
194+
- [`flexBasis`](https://facebook.github.io/react-native/docs/layout-props#flexbasis) is an axis-independent way of providing the default size of an item along the main axis. Setting the `flexBasis` of a child is similar to setting the `width` of that child if its parent is a container with `flexDirection: row` or setting the `height` of a child if its parent is a container with `flexDirection: column`. The `flexBasis` of an item is the default size of that item, the size of the item before any `flexGrow` and `flexShrink` calculations are performed.
195195

196-
LEARN MORE [HERE](https://yogalayout.com/docs/flex)
196+
You can learn more [here](https://yogalayout.com/docs/flex).
197197

198198
### Width and Height
199199

200-
The `width` property in Yoga specifies the width of the element's content area. Similarly height property specifies the `height` of the element's content area.
200+
The `width` property specifies the width of an element's content area. Similarly, the `height` property specifies the height of an element's content area.
201201

202-
Both `width` and `height` can take following values:
202+
Both `width` and `height` can take the following values:
203203

204-
- `auto` Is the **default Value**, React Native calculates the width/height for the element based on its content, whether that is other children, text, or an image.
204+
- `auto` (**default value**) React Native calculates the width/height for the element based on its content, whether that is other children, text, or an image.
205205

206206
- `pixels` Defines the width/height in absolute pixels. Depending on other styles set on the component, this may or may not be the final dimension of the node.
207207

208-
- `percentage` Defines the width or height in percentage of its parent's width or height respectively.
208+
- `percentage` Defines the width or height in percentage of its parent's width or height, respectively.
209209

210210
### Absolute & Relative Layout
211211

212212
The `position` type of an element defines how it is positioned within its parent.
213213

214-
`relative` (**default value**) By default an element is positioned relatively. This means an element is positioned according to the normal flow of the layout, and then offset relative to that position based on the values of `top`, `right`, `bottom`, and `left`. The offset does not affect the position of any sibling or parent elements.
214+
`relative` (**default value**) By default, an element is positioned relatively. This means an element is positioned according to the normal flow of the layout, and then offset relative to that position based on the values of `top`, `right`, `bottom`, and `left`. The offset does not affect the position of any sibling or parent elements.
215215

216-
`absolute` When positioned absolutely an element doesn't take part in the normal layout flow. It is instead laid out independent of its siblings. The position is determined based on the `top`, `right`, `bottom`, and `left` values.
216+
`absolute` When positioned absolutely, an element doesn't take part in the normal layout flow. It is instead laid out independent of its siblings. The position is determined based on the `top`, `right`, `bottom`, and `left` values.
217217

218218
![Absolute & Relative Layoutp](https://cdn-images-1.medium.com/max/800/1*NlPeRQCQK3Vb5nyjL0Mqxw.png)
219219

@@ -223,6 +223,6 @@ Check out the interactive [yoga playground](https://yogalayout.com/playground) t
223223

224224
We've covered the basics, but there are many other styles you may need for layouts. The full list of props that control layout is documented [here](./layout-props.md).
225225

226-
We're getting close to being able to build a real application. One thing we are still missing is a way to take user input, so let's move on to [learn how to handle text input with the TextInput component](handling-text-input.md).
226+
Additionally, you can see some examples from [Wix Engineers](https://medium.com/wix-engineering/the-full-react-native-layout-cheat-sheet-a4147802405c).
227227

228-
See some examples from [Wix Engineers](https://medium.com/wix-engineering/the-full-react-native-layout-cheat-sheet-a4147802405c):
228+
We're getting close to being able to build a real application. One thing we are still missing is a way to take user input, so let's move on to [learn how to handle text input with the TextInput component](handling-text-input.md).

0 commit comments

Comments
 (0)