Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline elements implementation

I want to create Text components and to display them in a row , like span elements in html. If i'm doing it this way:

<View>   <Text> Start here, </Text> <Text> finish here </Text> </View> 

line is broken between them and it looks like:

Start here,
finish here

How can i prevent line breaking and display them on the same line?

like image 909
Ivan Chernykh Avatar asked Jan 10 '16 11:01

Ivan Chernykh


People also ask

How do you make an inline element in HTML?

An inline element does not start on a new line. An inline element only takes up as much width as necessary. This is a <span> element inside a paragraph.

How do you change block level elements to inline elements in HTML?

You can set a block-level element to display like an inline element by setting the display property to inline. You can also cause inline elements to behave like block-level elements using the display property.


2 Answers

Just set the correct flexDirection. Default is column.

<View style={{flexDirection: 'row'}}>  <Text> Start here, </Text> <Text> finish here </Text> </View> 
like image 161
purii Avatar answered Sep 22 '22 20:09

purii


Text components are inline when wrapping them with another Text element, like:

<Text>    <Text>We</Text><Text>Are</Text><Text>Inline</Text> </Text> 
like image 28
Ivan Chernykh Avatar answered Sep 21 '22 20:09

Ivan Chernykh