Line with text in react native without using a library

Trying to replicate the below design but not able to. Will appreciate any help with this.

enter image description here

Code that I tried from my end is as below but the line overwrites the text.

<View>
  <View style={{ alignSelf:'center', borderBottomColor:'black', borderBottomWidth:1,height:'50%', width:'90%' }}/>
  <Text style={{ alignSelf:'center', paddingHorizontal:5 }}>Your class</Text>
</View>

Upvotes: 6

Views: 8040

Answers (1)

Val
Val

Reputation: 22797

Made it works this way:

<View style={{flexDirection: 'row'}}>
    <View style={{backgroundColor: 'black', height: 2, flex: 1, alignSelf: 'center'}} />
    <Text style={{ alignSelf:'center', paddingHorizontal:5, fontSize: 24 }}>Your class</Text>
    <View style={{backgroundColor: 'black', height: 2, flex: 1, alignSelf: 'center'}} />
</View>

enter image description here

Upvotes: 36

Related Questions