React-native view auto width by text inside

“alignSelf” does the same as ‘display: inline-block’ would in common HTML/CSS and it works very well for me.

<View style={{backgroundColor: '#000000', alignSelf: 'flex-start' }}>
 <Text style={{color: '#ffffff'}}>
  Sample text here
 </Text>
</View>

Leave a Comment