How does the alignItems flexBox property works?

You can think of alignItems as justifyContent behaviour for cross-axis. Cross-axis in the case if React native is the horizontal axis. CSS alignItems property sets the alignSelf value on all direct children as a group. In Flexbox, it controls the alignment of items on the cross-axis. By default, the cross axis is horizontal in the case of React native. We can use this property to layout elements in the flex container. The alignItems property supports following values: stretch|center|flex-start|flex-end|baseline|initial|inherit; Let me explain align items values: 

  1. flex-start: this is the default value for alignItems. It means that flex items will start from the left and be evenly distributed horizontally. 
  2. Flex-end: this is just the opposite behavior of flex-start. Elements start rendering from the right and go up to the left end. 
  3. Center: Items will be placed in the middle 
  4. Space-between: elements are evenly distributed along the cross-axis (horizontal axis) 
  5. Space-around: flex items will be evenly distributed with equal space around them 

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *