Rukshan
Rukshan

Reputation: 133

How to insert a tab to a Text in React Native

I want insert a tab to a text in react native before text. I tried in various ways but couldn't do it. Is there a way to do it by using a code like line break \n

<View> <Text>I want to shift this text right</Text> </View>

Upvotes: 2

Views: 11138

Answers (4)

Mars
Mars

Reputation: 4995

You could use &ensp; or &emsp;

The &ensp; character entity is used to denote an en space which means half point size of the current font. This may be perceived as twice the space of a normal space.

The &emsp; character entity is used to denote an em space which means equal to the point size of the current font. This may be perceived as four times the space of a normal space.

Upvotes: 0

Vinicius
Vinicius

Reputation: 1365

The way i do it is using a javascript string inside the JSX Text component. This way you can write strings the "programming way".

<Text>{`\tI want to shift this text right`}</Text>

Upvotes: 2

Oskar Dauksts
Oskar Dauksts

Reputation: 33

Try this

<Text> {`\t I want to shift this text right`} </Text>

Upvotes: 0

Thakur Karthik
Thakur Karthik

Reputation: 3518

This works too...

<Text>{'    '}Hello world</Text>

Upvotes: 0

Related Questions