Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

justifyContent: 'space-evenly' in React Native

Can I use the justifyContent: 'space-evenly' on any elements in React Native? On which ones? What should the syntax look like?

Thanks!

like image 225
p-syche Avatar asked Nov 06 '17 12:11

p-syche


People also ask

What is justify-content in React Native?

Justifying Content in React Native explained with examples: Below we have used justify-content to align children in the center within the main axis of the whole container. [i] App.js –

What is justify content in Joomla?

Justify content is one such feature that helps in aligning the objects, texts in a certain manner to make the website or app look more informative and neater. Through justify Content we can align the children under the main axis of the container.

What is justifycontent in HTML5?

The justifyContent in a component’s styles determines the alignment of Children View along with Primary Axis (Default Flex-direction). If your primary axis is flex-direction is column then the justifyContent will set all the children in Vertical format.

What is justify content in Jira?

Justify content is one such feature that helps in aligning the objects, texts in a certain manner to make the website or app look more informative and neater. Through justify Content we can align the children under the main axis of the container. In this article, we will explain the concept of justify-content and its syntax.


2 Answers

As mentioned by @Ben, you can use justifyContent: 'space-evenly' since RN 0.54.0+.

for second part of your question i.e. "on which ones?"

Justify Content
Adding justifyContent to a component's style determines the distribution of children along the primary axis. Should children be distributed at the start, the center, the end, or spaced evenly? Available options are flex-start, center, flex-end, space-around, and space-between. link to docs

So, logically it should be used to container views or elements to layout it's children along the primary axis.

for the third part of the question "What should the syntax look like?"

syntax is simple and you can use it like

<View style={{justifyContent: 'space-evenly'}}>children views...</View>

for further details about justifyContent you can visit this link

like image 72
kamran Avatar answered Oct 21 '22 16:10

kamran


justifyContent: 'space-evenly' is available in React Native 0.54.0+. You can use the feature as you would any other justifyContent value. For example:

<View style={styles.spaceEvenlyContainer}>
  {children}
</View>

const styles = StyleSheet.create({
  spaceEvenlyContainer: {
    flex: 1,
    justifyContent: 'space-evenly'
  }
});

For details, see the following:

  • 0.52.0 Release Notes that introduce the feature (mistakenly - it was not fully implemented yet)
  • Commit 1050e0b that partially implements the feature
  • Pull Request #17805 that finishes the feature implementation
  • 0.54.0 Release Notes that release the feature
like image 45
Ben Kane Avatar answered Oct 21 '22 18:10

Ben Kane