Yoga Docs: Rename website-next
to website
(#1613)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1613 So that GitHub links to edit a page point to the right place. This will fail in OSS build until I switch the directory used by Vercel instance, but I am waiting to do that until ready to land, since that would cause other in progress changes to fail when exported. Reviewed By: joevilches Differential Revision: D54837857
This commit is contained in:
committed by
Facebook GitHub Bot
parent
108c2f30a2
commit
e959e79610
4
website/docs/styling/_category_.json
Normal file
4
website/docs/styling/_category_.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"label": "Styling",
|
||||
"position": 4
|
||||
}
|
47
website/docs/styling/align-content.mdx
Normal file
47
website/docs/styling/align-content.mdx
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Align Content
|
||||
|
||||
Align content defines the distribution of lines along the cross-axis. This only
|
||||
has effect when items are wrapped to multiple lines using [flex wrap](/docs/styling/flex-wrap).
|
||||
|
||||
**Flex start (default)**: Align wrapped lines to the start of the container's cross axis.
|
||||
|
||||
**Flex end**: Align wrapped lines to the end of the container's cross axis.
|
||||
|
||||
**Stretch**: Stretch wrapped lines to match the [height](/docs/styling/width-height) of the container's cross axis.
|
||||
|
||||
**Center**: Align wrapped lines in the center of the container's cross axis.
|
||||
|
||||
**Space between**: Evenly space wrapped lines across the container's main axis, distributing
|
||||
remaining space between the lines.
|
||||
|
||||
**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.
|
||||
|
||||
**Space evenly**: Evenly space wrapped lines across the container's main axis, distributing
|
||||
remaining space around the lines. Compared to space around, space evenly will not
|
||||
double the gaps between children. The size of gaps between children and between
|
||||
the parent's edges and the first/last child will all be equal.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 250,
|
||||
padding: 10,
|
||||
alignContent: 'flex-start',
|
||||
flexWrap: 'wrap',
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
48
website/docs/styling/align-items-self.mdx
Normal file
48
website/docs/styling/align-items-self.mdx
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Align Items
|
||||
|
||||
Align items describes how to align children along the cross axis of their container.
|
||||
Align items is very similar to [justify content](/docs/styling/justify-content) but instead of
|
||||
applying to the main axis, align items applies to the cross axis.
|
||||
|
||||
**Stretch (default)**: Stretch children of a container to match the [height](/docs/styling/width-height) of the container's cross axis.
|
||||
|
||||
**Flex start**: Align children of a container to the start of the container's cross axis.
|
||||
|
||||
**Flex end**: Align children of a container to the end of the container's cross axis.
|
||||
|
||||
**Center**: Align children of a container in the center of the container's cross axis.
|
||||
|
||||
**Baseline**: Align children of a container along a common baseline. Individual children can be set to be the reference baseline for their parents.
|
||||
|
||||
# Align Self
|
||||
|
||||
Align self has the same options and effect as align items but instead of
|
||||
affecting the children within a container, you can apply this property to
|
||||
a single child to change its alignment within its parent. Align self
|
||||
overrides any option set by the parent with align items.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 250,
|
||||
padding: 10,
|
||||
alignItems: 'flex-start',
|
||||
}}>
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
height: 50,
|
||||
width: 50,
|
||||
alignSelf: 'center',
|
||||
}}
|
||||
/>
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
27
website/docs/styling/aspect-ratio.mdx
Normal file
27
website/docs/styling/aspect-ratio.mdx
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Aspect Ratio
|
||||
|
||||
The aspect ratio property in Yoga has the following properties:
|
||||
|
||||
- Accepts any floating point value > 0, the default is undefined.
|
||||
- Defined as the ratio between the [width](/docs/styling/width-height) and the [height](/docs/styling/width-height) of a node e.g. if a node has an aspect ratio of 2 then its [width](/docs/styling/width-height) is twice the size of its [height](/docs/styling/width-height).
|
||||
- Respects the [min](/docs/styling/min-max-width-height) and [max](/docs/styling/min-max-width-height) dimensions of an item.
|
||||
- Has higher priority than [flex grow](/docs/styling/flex-basis-grow-shrink)
|
||||
- If aspect ratio, [width](/docs/styling/width-height), and [height](/docs/styling/width-height) are set then the cross axis dimension is overridden.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 50, aspectRatio: 1.0}} />
|
||||
<Node style={{margin: 5, height: 50, aspectRatio: 1.5}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
25
website/docs/styling/display.mdx
Normal file
25
website/docs/styling/display.mdx
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Display
|
||||
|
||||
Display controls which layout specification to follow.
|
||||
|
||||
**Flex (default)**: The CSS Flexible Box Model specification.
|
||||
|
||||
**None**: The node is removed from the layout tree and will not be visible.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 50, display: 'none'}} />
|
||||
<Node style={{margin: 5, height: 50, display: 'flex'}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
65
website/docs/styling/flex-basis-grow-shrink.mdx
Normal file
65
website/docs/styling/flex-basis-grow-shrink.mdx
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Flex Basis, Grow, and Shrink
|
||||
|
||||
**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](/docs/styling/width-height) of that
|
||||
child if its parent is a container with a row [flex direction](/docs/styling/flex-direction) or setting the [height](/docs/styling/width-height) of a child
|
||||
if its parent is a container with a column [flex direction](/docs/styling/flex-direction). 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.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node style={{margin: 5, flexBasis: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
||||
|
||||
**Flex grow**: 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.
|
||||
|
||||
Flex grow 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.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node style={{margin: 5, flexGrow: 0.25}} />
|
||||
<Node style={{margin: 5, flexGrow: 0.75}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
||||
|
||||
**Flex shrink**: 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.
|
||||
|
||||
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.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node style={{margin: 5, flexShrink: 5, height: 150}} />
|
||||
<Node style={{margin: 5, flexShrink: 10, height: 150}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
37
website/docs/styling/flex-direction.mdx
Normal file
37
website/docs/styling/flex-direction.mdx
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
sidebar_position: 6
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Flex Direction
|
||||
|
||||
Flex direction controls the direction in which children of a node are laid out.
|
||||
This is also referred to as the main axis. The main axis is the direction in
|
||||
which children are laid out. The cross axis is the axis perpendicular to the
|
||||
main axis, or the axis which wrapping lines are laid out in.
|
||||
|
||||
**Column (default)**: Align children from top to bottom. If [wrapping](/docs/styling/flex-wrap) is enabled then
|
||||
the next line will start to the left first item on the top of the container.
|
||||
|
||||
**Row**: Align children from left to right. If [wrapping](/docs/styling/flex-wrap) is enabled then
|
||||
the next line will start under the first item on the left of the container.
|
||||
|
||||
**Row reverse**: Align children from right to left. If [wrapping](/docs/styling/flex-wrap) is enabled then
|
||||
the next line will start under the first item on the right of the container.
|
||||
|
||||
**Column reverse**: Align children from bottom to top. If [wrapping](/docs/styling/flex-wrap) is enabled then
|
||||
the next line will start to the left first item on the bottom of the container.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
flexDirection: 'column',
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
33
website/docs/styling/flex-wrap.mdx
Normal file
33
website/docs/styling/flex-wrap.mdx
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
sidebar_position: 7
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Flex Wrap
|
||||
|
||||
The flex wrap 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 nodes). When wrapping lines [align content](/docs/styling/align-content) can be used to specify how the
|
||||
lines are placed in the container.
|
||||
|
||||
**No wrap (default)**: No wrapping and children might shrink as a result.
|
||||
|
||||
**Wrap**: Nodes are wrapped into multiple lines along the main axis if needed.
|
||||
|
||||
**Wrap reverse**: Behaves the same as wrap but the order of the lines is reversed.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 250,
|
||||
padding: 10,
|
||||
flexWrap: 'wrap',
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
49
website/docs/styling/gap.mdx
Normal file
49
website/docs/styling/gap.mdx
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
sidebar_position: 8
|
||||
---
|
||||
import Playground from '@site/src/components/Playground';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# Gap
|
||||
|
||||
Gap will add spacing between the rows and columns of a flex container. You can
|
||||
specify if you want the gaps to be between only the rows, only the columns, or
|
||||
both. You can do this by passing in the corresponding gutter value to the API,
|
||||
for example
|
||||
|
||||
<Tabs groupId="language">
|
||||
<TabItem value="cpp" label="C/C++">
|
||||
```cpp
|
||||
YGNodeStyleSetGap(node, YGGutterRow, amount);
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="java" label="Java">
|
||||
```java
|
||||
node.setGap(YogaGutter.ROW, amount);
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="ts" label="Typescript">
|
||||
```typescript
|
||||
node.setGap(Gutter.Row, amount);
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 250,
|
||||
padding: 10,
|
||||
flexWrap: 'wrap',
|
||||
gap: 10,
|
||||
}}>
|
||||
<Node style={{height: 50, width: 50}} />
|
||||
<Node style={{height: 50, width: 50}} />
|
||||
<Node style={{height: 50, width: 50}} />
|
||||
<Node style={{height: 50, width: 50}} />
|
||||
<Node style={{height: 50, width: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
47
website/docs/styling/index.md
Normal file
47
website/docs/styling/index.md
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# 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:
|
||||
|
||||
1. `flex-direction` defaults to `column` instead of `row`
|
||||
2. `align-content` defaults to `flex-start` instead of `stretch`
|
||||
3. `flex-shrink` defaults to `0` instead of `1`
|
||||
4. `position` defaults to `relative` instead of `static`
|
||||
|
||||
Yoga may be [configured](../getting-started/configuring-yoga.mdx) to align to the defaults on web for `flex-direction`, `align-content`, and `flex-shrink` by setting the `UseWebDefaults` flag.
|
||||
|
||||
:::warning
|
||||
|
||||
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'`](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing) 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:
|
||||
1. Relative to writing direction (start/end)
|
||||
2. A physical edge (top/right/left/bottom)
|
||||
3. 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.
|
62
website/docs/styling/insets.mdx
Normal file
62
website/docs/styling/insets.mdx
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
sidebar_position: 8.5
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# Insets
|
||||
|
||||
Insets refer to the position property that you can assign to an edge
|
||||
(not to be confused with [position type](/docs/styling/position)) using one of the following
|
||||
APIs:
|
||||
<Tabs groupId="language">
|
||||
<TabItem value="cpp" label="C/C++">
|
||||
```cpp
|
||||
YGNodeStyleSetPosition(node, edge, position);
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="java" label="Java">
|
||||
```java
|
||||
node.setPosition(edge, position);
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="ts" label="Typescript">
|
||||
```typescript
|
||||
node.setPosition(edge, position);
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
This property will offset the node in a specific way depending on
|
||||
what [position type](/docs/styling/position) the node has.
|
||||
|
||||
* If the node is static then insets have no effect.
|
||||
* If the node is relative then insets will move the node the designated amount
|
||||
from where the node would normally be in the container. Each inset property
|
||||
is relative to the node's corresponding physical edge. So `YGNodeStyleSetPosition(node, YGEdgeRight, 10.0f)` will offset the node
|
||||
so that the right edge is 10 units away from where the right edge would be originally.
|
||||
* If the node is aboslute then insets will move the node the designated amount away from
|
||||
the node's [containing block](/docs/advanced/containing-block). So `YGNodeStyleSetPosition(node, YGEdgeRight, 10.0f)`
|
||||
will offset the node so that the right edge is 10 units away from the [containing block's](/docs/advanced/containing-block)
|
||||
right edge.
|
||||
|
||||
In the event that a node has a fixed size and opposite insets are defined
|
||||
(e.g. a value assigned to the right edge and left edge) then the left and top edge will have priority.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
}}>
|
||||
<Node
|
||||
style={{
|
||||
height: 50,
|
||||
width: 50,
|
||||
top: 50,
|
||||
left: 50,
|
||||
}}
|
||||
/>
|
||||
</Node>
|
||||
</Layout>`} />
|
43
website/docs/styling/justify-content.mdx
Normal file
43
website/docs/styling/justify-content.mdx
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
sidebar_position: 9
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Justify Content
|
||||
|
||||
Justify content describes how to align children within the main axis of their container.
|
||||
For example, you can use this property to center a child horizontally within a container
|
||||
with [flex direction](/docs/styling/flex-direction) set to row or vertically within a container with [flex direction](/docs/styling/flex-direction)
|
||||
set to column.
|
||||
|
||||
**Flex start (default)**: Align children of a container to the start of the container's main axis.
|
||||
|
||||
**Flex end**: Align children of a container to the end of the container's main axis.
|
||||
|
||||
**Center**: Align children of a container in the center of the container's main axis.
|
||||
|
||||
**Space between**: Evenly space of children across the container's main axis, distributing
|
||||
remaining space between the children.
|
||||
|
||||
**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.
|
||||
|
||||
**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.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
justifyContent: 'flex-start',
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
34
website/docs/styling/layout-direction.mdx
Normal file
34
website/docs/styling/layout-direction.mdx
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
sidebar_position: 10
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Layout Direction
|
||||
|
||||
Layout direction specifies the direction in which children and text
|
||||
in a hierarchy should be laid out. Layout direction also effects what
|
||||
edge `start` and `end` refer to. By default Yoga lays out with left-to-right (LTR)
|
||||
layout direction. In this mode `start` refers to `left` and `end`
|
||||
refers to `right`. When localizing your apps for markets with right-to-left (RTL) languages
|
||||
you should customize this by either by passing a direction
|
||||
to the [CalculateLayout](/docs/getting-started/laying-out-a-tree) call or by setting the direction on the root node.
|
||||
|
||||
**LTR (default)**: Text and children and laid out from left to right. Styles applied
|
||||
the start of an element are applied on the left side.
|
||||
|
||||
**RTL**: Text and children and laid out from right to left. Styles applied the
|
||||
start of an element are applied on the right side.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
direction: 'ltr',
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
<Node style={{margin: 5, height: 50, width: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
41
website/docs/styling/margin-padding-border.mdx
Normal file
41
website/docs/styling/margin-padding-border.mdx
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
sidebar_position: 11
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Margin, Padding, and Border
|
||||
|
||||
**Margin**: Affects the spacing around the outside of a node. A node with margin
|
||||
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.
|
||||
|
||||
**Padding**: Affects the size of the node it is applied to. Padding in Yoga acts as if
|
||||
`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.
|
||||
|
||||
**Border**: in Yoga acts exactly like padding and only exists as a seperate property so
|
||||
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.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
padding: 20,
|
||||
borderWidth: 20,
|
||||
height: 50,
|
||||
}}
|
||||
/>
|
||||
<Node style={{height: 50}} />
|
||||
</Node>
|
||||
</Layout>`} />
|
52
website/docs/styling/min-max-width-height.mdx
Normal file
52
website/docs/styling/min-max-width-height.mdx
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
sidebar_position: 12
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Min/Max Width and Height
|
||||
|
||||
These properties set the maximum and minimum size constraints of a node.
|
||||
They have higher priority than all other properties and will always be respected.
|
||||
Constraints can be specified as either absolute pixel values or as percentages of their
|
||||
[containing block's](/docs/advanced/containing-block) size. By default all these constraints are `undefined`.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 250,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node style={{margin: 5, height: 25}} />
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
height: 100,
|
||||
maxHeight: 25,
|
||||
}}
|
||||
/>
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
height: 25,
|
||||
minHeight: 50,
|
||||
}}
|
||||
/>
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
height: 25,
|
||||
maxWidth: 25,
|
||||
}}
|
||||
/>
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
height: 25,
|
||||
width: 25,
|
||||
minWidth: 50,
|
||||
}}
|
||||
/>
|
||||
</Node>
|
||||
</Layout>`} />
|
37
website/docs/styling/position.mdx
Normal file
37
website/docs/styling/position.mdx
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
sidebar_position: 11
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Position
|
||||
|
||||
**Relative (default)**: This node is laid out according to the specified flow of the flex container it is apart of.
|
||||
That is, it particpates in the flexbox algorithm and will take up space within the container, unlike absolute.
|
||||
[Insets](/docs/styling/insets) will offset the node from its normal position within its container.
|
||||
This node will always form a [containing block](/docs/advanced/containing-block).
|
||||
|
||||
**Absolute**: This node is removed from the specified flow of the flex container it is apart of.
|
||||
Absolute nodes do not take up space in its flex container and will not affect the position of
|
||||
its siblings. [Insets](/docs/styling/insets) will offset the node from its [containing block](/docs/advanced/containing-block).
|
||||
|
||||
**Static**: This node behaves like relative except it will ignore [insets](/docs/styling/insets) and will not
|
||||
form a [containing block](/docs/advanced/containing-block).
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
height: 50,
|
||||
top: 20,
|
||||
position: 'relative',
|
||||
}}
|
||||
/>
|
||||
</Node>
|
||||
</Layout>`} />
|
37
website/docs/styling/width-height.mdx
Normal file
37
website/docs/styling/width-height.mdx
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
sidebar_position: 14
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
# Width and Height
|
||||
|
||||
The width property specifies the width of the node's border box (the collective size of the node's content, padding, and border).
|
||||
Similarly height property specifies the height of the node's border box.
|
||||
|
||||
Both width and height can take following values:
|
||||
|
||||
**Auto**: The default Value, Yoga calculates the width/height for the node based
|
||||
on its content, whether that is other children, text, or an image.
|
||||
|
||||
**Pixels**: Defines the width/height in absolute pixels. Depending on other properties set on
|
||||
the Yoga node this may or may not be the final dimension of the node.
|
||||
|
||||
**Percentage**: Defines the width or height in percentage of its [containing block's](/docs/advanced/containing-block) width or height respectively.
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 200,
|
||||
height: 200,
|
||||
padding: 10,
|
||||
}}>
|
||||
<Node
|
||||
style={{
|
||||
margin: 5,
|
||||
height: 50,
|
||||
width: 50,
|
||||
}}
|
||||
/>
|
||||
</Node>
|
||||
</Layout>`} />
|
Reference in New Issue
Block a user