I am trying to understand the FlexBox implementation on React Native and find it very unfortunate that Facebook's documentation doesn't provide any info at all on what the individual properties mean. They only name the ones that they have implemented without further documentation...
I love the Flexbox in 5 tutorial, it does an amazing job in explaining the most important FlexBox properties. However, there is no mention of the alignSelf
property there and I also didn't find documentation about this one elsewhere...
Can someone explain (maybe even demonstrate visually) what the difference between the two is? I also appreciate links to any resources that explain the React Native FlexBox properties in more detail and provide some guidance in using them.
The align-content property determines how flex lines are aligned along the cross-axis while the align-items property determines how flex items are aligned within a flex line and along the cross-axis.
Normally you will use flex: 1 , which tells a component to fill all available space, shared evenly amongst other components with the same parent. The larger the flex given, the higher the ratio of space a component will take compared to its siblings.
Flex Wrap The 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).
Syntax: justify-content: flex-start|flex-end|center|space-between| space-around|space-evenly; Property Values: flex-start: It is the default value of justifyContent.
alignItems
and alignSelf
have the same functionality per se. The only difference being, alignItems
applies the alignment on to it's children while alignSelf
applies the alignment to itself. This is useful when you want to change the alignment of one child.
Here is an illustration from https://css-tricks.com/snippets/css/a-guide-to-flexbox/
The above happens when the container has a style alignItems:'flex-start'
This happens when the container has the style alignItems:'flex-start'
and the third child has the style alignSelf:'flex-end
alignSelf
can override the alignItems
value for specific items.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With