why does the text occupy the entire presentation space and not just "Hello"?
Since View is a flexible container and by default has flexDirection: 'column' and alignItems: 'stretch' , this means that its child alignItems: 'stretch' must be stretched to fill its width.
(Note that for Docs , all components in React Native are display: 'flex' by default and display: 'inline' . Doesnβt exist at all. Therefore, the default behavior for Text inside a View in React Native is different from the default behavior for span within the div within the network, in the latter case, the span will not fill the width of the div because the span is a built-in element by default. There is no such thing in React Native.)
How can text be moved / aligned right?
The float property does not exist in React Native, but there are many options available to you (with slightly different behavior) that will allow you to align the text to the right. Here are the ones I can think of:
<View> <Text style={{textAlign: 'right'}}>Hello, World!</Text> </View>
(This approach does not alter the fact that Text fills the entire width of the View ; it right justifies the text in Text .)
<View> <Text style={{alignSelf: 'flex-end'}}>Hello, World!</Text> </View>
This shrinks the Text element to the size needed to hold its contents and places it at the end of the transverse direction (horizontal direction, by default) from the View .
<View style={{alignItems: 'flex-end'}}> <Text>Hello, World!</Text> </View>
This is equivalent to setting alignSelf: 'flex-end' on all alignSelf: 'flex-end' View .
<View style={{flexDirection: 'row', justifyContent: 'flex-end'}}> <Text>Hello, World!</Text> </View>
flexDirection: 'row' sets the main direction of the layout as horizontal rather than vertical; justifyContent similar to alignItems , but controls alignment in the main direction, not in the transverse direction.
<View style={{flexDirection: 'row'}}> <Text style={{marginLeft: 'auto'}}>Hello, World!</Text> </View>
This approach is demonstrated in the context of the Internet and real CSS at https://stackoverflow.com/a/212632/2/16 .
<View> <Text style={{position: 'absolute', right: 0}}>Hello, World!</Text> </View>
As in real CSS, this takes Text out of the stream, which means that its siblings will be able to overlap it, and its vertical position will default to the top of the View (although you can explicitly set the distance from the top). from View using the top style property).
Naturally, which of these various approaches you want to use - and whether the choice between them is important at all - will depend on your specific circumstances.