Navigate back to the homepage

React Native Text

Infinitbility
Text
January 27th, 2021 · 1 min read

This Article Part of React Native Tutorial Series want to start from scrach follow below link

https://infinitbility.com/react-native/table-of-contents


Text

The Text component is one of the most common React Native components — we use it whenever we need to display text in our app.

This component can be nested and it can inherit properties from parent to child. This can be useful in many ways. We will show you example of capitalizing the first letter, styling words or parts of the text, etc.

React Native Text example

1import React, { Component } from "react";
2import { Text, StyleSheet } from "react-native";
3
4class ReactNativeText extends Component {
5 constructor(props) {
6 super(props);
7 this.state = {
8 titleText: "Infinitbility",
9 bodyText: "We have the ability to build infinite way for us."
10 };
11 }
12
13 render() {
14 return (
15 <Text style={styles.baseText}>
16 <Text style={styles.titleText} onPress={this.onPressTitle}>
17 {this.state.titleText}
18 {"\n"}
19 {"\n"}
20 </Text>
21 <Text numberOfLines={5}>{this.state.bodyText}</Text>
22 </Text>
23 );
24 }
25}
26
27const styles = StyleSheet.create({
28 baseText: {
29 fontFamily: "Cochin",
30 padding: 20,
31 textAlign: 'center',
32 },
33 titleText: {
34 fontSize: 20,
35 fontWeight: "bold"
36 }
37});
38
39export default ReactNativeText;

Common Q & A

Common Q & A section explain commonly question ask on google.

How do I add text in react native?

Alrady added example on Text Section but hear explaining steps to add Text.

First import Text component from react native.

1import { Text } from "react-native";

and use like below.

1<Text>Text Goes Here</Text>

How do you justify text in react native?

1<Text style={{textAlign: 'justify'}}>Text Goes Here</Text>

How do I align text to the right in react native?

1<Text style={{textAlign: 'right'}}>Text Goes Here</Text>

How do you strike text in react native?

1<Text style={{textDecorationLine: 'line-through',textDecorationStyle: 'solid'}}>Text Goes Here</Text>

How do I change the text color in react native?

1<Text style={{color: '#ffffff'}}>Text Goes Here</Text>

How do I center text in react native?

1<Text style={{color: '#center'}}>Text Goes Here</Text>

More From React Native Tutorial

Basics

Advances

Error & Issue Solution

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

More articles from Infinitbility

React Native Flexbox

React Native Tutorial - React Native Flexbox

January 24th, 2021 · 3 min read

React Native Styling

React Native Tutorial - React Native Styling

January 17th, 2021 · 1 min read
© 2021 Infinitbility
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]