Categories
React Answers

How to set an item to have position absolute center with React Native?

Spread the love

To set an item to have position absolute center with React Native, we can set the position to absolute.

Then we set justifyContent and alignItems to center to center out item.

For instance, we write

<View
  style={{
    position: "absolute",
    top: 0,
    left: 0,
    right: 0,
    bottom: 0,
    justifyContent: "center",
    alignItems: "center",
  }}
>
  <Text>text here ...</Text>
</View>

to set the position, top, left, right and bottom values.

Then we center our View by setting justifyContent and alignItems to center.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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