A React component for displaying text which supports nesting, styling, and touch handling. In the following example, the nested title and body text will inherit the fontFamily
from styles.baseText
, but the title provides its own additional styles. The title and body will stack on top of each other on account of the literal newlines:
renderText: function() { return ( <Text style={styles.baseText}> <Text style={styles.titleText} onPress={this.onPressTitle}> {this.state.titleText + '\n\n'} </Text> <Text numberOfLines={5}> {this.state.bodyText} </Text> </Text> ); }, ... var styles = StyleSheet.create({ baseText: { fontFamily: 'Cochin', }, titleText: { fontSize: 20, fontWeight: 'bold', }, };
Props
accessible
numberOfLines number
Used to truncate the text with an ellipsis after computing the text layout, including line wrapping, such that the total number of lines does not exceed this number.
onLayout function
Invoked on mount and layout changes with
{nativeEvent: {layout: {x, y, width, height}}}
onLongPress function
This function is called on long press.
onPress function
This function is called on press.
style style
View#style...
color color
fontFamily string
fontSize number
fontStyle enum('normal', 'italic')
fontWeight enum('normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')
Specifies font weight. The values 'normal' and 'bold' are supported for most fonts. Not all fonts have a variant for each of the numeric values, in that case the closest one is chosen.
lineHeight number
textAlign enum('auto', 'left', 'right', 'center', 'justify')
Specifies text alignment. The value 'justify' is only supported on iOS and fallbacks to left
on Android.
textDecorationLine enum('none', 'underline', 'line-through', 'underline line-through')
textShadowColor color
textShadowOffset {width: number, height: number}
textShadowRadius number
androidtextAlignVertical enum('auto', 'top', 'bottom', 'center')
iosletterSpacing number
iostextDecorationColor color
iostextDecorationStyle enum('solid', 'double', 'dotted', 'dashed')
ioswritingDirection enum('auto', 'ltr', 'rtl')
testID string
Used to locate this view in end-to-end tests.
iosallowFontScaling bool
Specifies should fonts scale to respect Text Size accessibility setting on iOS.
iossuppressHighlighting bool
When true, no visual change is made when text is pressed down. By default, a gray oval highlights the text on press down.
Description
Nested Text
Both iOS and Android allow you to display formatted text by annotating ranges of a string with specific formatting like bold or colored text (NSAttributedString
on iOS, SpannableString
on Android). In practice, this is very tedious. For React Native, we decided to use web paradigm for this where you can nest text to achieve the same effect.
<Text style={{fontWeight: 'bold'}}> I am bold <Text style={{color: 'red'}}> and red </Text> </Text>
Behind the scenes, React Native converts this to a flat NSAttributedString
or SpannableString
that contains the following information:
"I am bold and red" 0-9: bold 9-17: bold, red
Nested Views (iOS Only)
On iOS, you can nest views within your Text component. Here's an example:
<Text> There is a blue square <View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} /> in between my text. </Text>
In order to use this feature, you must give the view a width
and a height
.
Containers
The <Text>
element is special relative to layout: everything inside is no longer using the flexbox layout but using text layout. This means that elements inside of a <Text>
are no longer rectangles, but wrap when they see the end of the line.
<Text> <Text>First part and </Text> <Text>second part</Text> </Text> // Text container: all the text flows as if it was one // |First part | // |and second | // |part | <View> <Text>First part and </Text> <Text>second part</Text> </View> // View container: each text is its own block // |First part | // |and | // |second part|
Limited Style Inheritance
On the web, the usual way to set a font family and size for the entire document is to write:
/* CSS, *not* React Native */ html { font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 11px; color: #141823; }
When the browser is trying to render a text node, it's going to go all the way up to the root element of the tree and find an element with a font-size
attribute. An unexpected property of this system is that any node can have font-size
attribute, including a <div>
. This was designed for convenience, even though not really semantically correct.
In React Native, we are more strict about it: you must wrap all the text nodes inside of a <Text>
component; you cannot have a text node directly under a <View>
.
// BAD: will raise exception, can't have a text node as child of a <View> <View> Some text </View> // GOOD <View> <Text> Some text </Text> </View>
You also lose the ability to set up a default font for an entire subtree. The recommended way to use consistent fonts and sizes across your application is to create a component MyAppText
that includes them and use this component across your app. You can also use this component to make more specific components like MyAppHeaderText
for other kinds of text.
<View> <MyAppText>Text styled with the default font for the entire application</MyAppText> <MyAppHeaderText>Text styled as a header</MyAppHeaderText> </View>
React Native still has the concept of style inheritance, but limited to text subtrees. In this case, the second part will be both bold and red.
<Text style={{fontWeight: 'bold'}}> I am bold <Text style={{color: 'red'}}> and red </Text> </Text>
We believe that this more constrained way to style text will yield better apps:
(Developer) React components are designed with strong isolation in mind: You should be able to drop a component anywhere in your application, trusting that as long as the props are the same, it will look and behave the same way. Text properties that could inherit from outside of the props would break this isolation.
(Implementor) The implementation of React Native is also simplified. We do not need to have a
fontFamily
field on every single element, and we do not need to potentially traverse the tree up to the root every time we display a text node. The style inheritance is only encoded inside of the native Text component and doesn't leak to other components or the system itself.
Examples
IOS |
Edit on GitHub |
'use strict'; var React = require('react'); var ReactNative = require('react-native'); var { Image, StyleSheet, Text, View, } = ReactNative; var Entity = React.createClass({ render: function() { return ( <Text style={{fontWeight: '500', color: '#527fe4'}}> {this.props.children} </Text> ); } }); var AttributeToggler = React.createClass({ getInitialState: function() { return {fontWeight: 'bold', fontSize: 15}; }, toggleWeight: function() { this.setState({ fontWeight: this.state.fontWeight === 'bold' ? 'normal' : 'bold' }); }, increaseSize: function() { this.setState({ fontSize: this.state.fontSize + 1 }); }, render: function() { var curStyle = {fontWeight: this.state.fontWeight, fontSize: this.state.fontSize}; return ( <View> <Text style={curStyle}> Tap the controls below to change attributes. </Text> <Text> <Text>See how it will even work on <Text style={curStyle}>this nested text</Text></Text> </Text> <Text style={{backgroundColor: '#ffaaaa', marginTop: 5}} onPress={this.toggleWeight}> Toggle Weight </Text> <Text style={{backgroundColor: '#aaaaff', marginTop: 5}} onPress={this.increaseSize}> Increase Size </Text> </View> ); } }); exports.title = '<Text>'; exports.description = 'Base component for rendering styled text.'; exports.displayName = 'TextExample'; exports.examples = [ { title: 'Wrap', render: function() { return ( <Text> The text should wrap if it goes on multiple lines. See, this is going to the next line. </Text> ); }, }, { title: 'Padding', render: function() { return ( <Text style={{padding: 10}}> This text is indented by 10px padding on all sides. </Text> ); }, }, { title: 'Font Family', render: function() { return ( <View> <Text style={{fontFamily: 'Cochin'}}> Cochin </Text> <Text style={{fontFamily: 'Cochin', fontWeight: 'bold'}}> Cochin bold </Text> <Text style={{fontFamily: 'Helvetica'}}> Helvetica </Text> <Text style={{fontFamily: 'Helvetica', fontWeight: 'bold'}}> Helvetica bold </Text> <Text style={{fontFamily: 'Verdana'}}> Verdana </Text> <Text style={{fontFamily: 'Verdana', fontWeight: 'bold'}}> Verdana bold </Text> </View> ); }, }, { title: 'Font Size', render: function() { return ( <View> <Text style={{fontSize: 23}}> Size 23 </Text> <Text style={{fontSize: 8}}> Size 8 </Text> </View> ); }, }, { title: 'Color', render: function() { return ( <View> <Text style={{color: 'red'}}> Red color </Text> <Text style={{color: 'blue'}}> Blue color </Text> </View> ); }, }, { title: 'Font Weight', render: function() { return ( <View> <Text style={{fontSize: 20, fontWeight: '100'}}> Move fast and be ultralight </Text> <Text style={{fontSize: 20, fontWeight: '200'}}> Move fast and be light </Text> <Text style={{fontSize: 20, fontWeight: 'normal'}}> Move fast and be normal </Text> <Text style={{fontSize: 20, fontWeight: 'bold'}}> Move fast and be bold </Text> <Text style={{fontSize: 20, fontWeight: '900'}}> Move fast and be ultrabold </Text> </View> ); }, }, { title: 'Font Style', render: function() { return ( <View> <Text style={{fontStyle: 'normal'}}> Normal text </Text> <Text style={{fontStyle: 'italic'}}> Italic text </Text> </View> ); }, }, { title: 'Text Decoration', render: function() { return ( <View> <Text style={{textDecorationLine: 'underline', textDecorationStyle: 'solid'}}> Solid underline </Text> <Text style={{textDecorationLine: 'underline', textDecorationStyle: 'double', textDecorationColor: '#ff0000'}}> Double underline with custom color </Text> <Text style={{textDecorationLine: 'underline', textDecorationStyle: 'dashed', textDecorationColor: '#9CDC40'}}> Dashed underline with custom color </Text> <Text style={{textDecorationLine: 'underline', textDecorationStyle: 'dotted', textDecorationColor: 'blue'}}> Dotted underline with custom color </Text> <Text style={{textDecorationLine: 'none'}}> None textDecoration </Text> <Text style={{textDecorationLine: 'line-through', textDecorationStyle: 'solid'}}> Solid line-through </Text> <Text style={{textDecorationLine: 'line-through', textDecorationStyle: 'double', textDecorationColor: '#ff0000'}}> Double line-through with custom color </Text> <Text style={{textDecorationLine: 'line-through', textDecorationStyle: 'dashed', textDecorationColor: '#9CDC40'}}> Dashed line-through with custom color </Text> <Text style={{textDecorationLine: 'line-through', textDecorationStyle: 'dotted', textDecorationColor: 'blue'}}> Dotted line-through with custom color </Text> <Text style={{textDecorationLine: 'underline line-through'}}> Both underline and line-through </Text> </View> ); }, }, { title: 'Nested', description: 'Nested text components will inherit the styles of their ' + 'parents (only backgroundColor is inherited from non-Text parents). ' + '<Text> only supports other <Text> and raw text (strings) as children.', render: function() { return ( <View> <Text> (Normal text, <Text style={{fontWeight: 'bold'}}> (and bold <Text style={{fontSize: 11, color: '#527fe4'}}> (and tiny inherited bold blue) </Text> ) </Text> ) </Text> <Text style={{opacity:0.7}}> (opacity <Text> (is inherited <Text style={{opacity:0.7}}> (and accumulated <Text style={{backgroundColor:'#ffaaaa'}}> (and also applies to the background) </Text> ) </Text> ) </Text> ) </Text> <Text style={{fontSize: 12}}> <Entity>Entity Name</Entity> </Text> </View> ); }, }, { title: 'Text Align', render: function() { return ( <View> <Text> auto (default) - english LTR </Text> <Text> أحب اللغة العربية auto (default) - arabic RTL </Text> <Text style={{textAlign: 'left'}}> left left left left left left left left left left left left left left left </Text> <Text style={{textAlign: 'center'}}> center center center center center center center center center center center </Text> <Text style={{textAlign: 'right'}}> right right right right right right right right right right right right right </Text> <Text style={{textAlign: 'justify'}}> justify: this text component{"'"}s contents are laid out with "textAlign: justify" and as you can see all of the lines except the last one span the available width of the parent container. </Text> </View> ); }, }, { title: 'Letter Spacing', render: function() { return ( <View> <Text style={{letterSpacing: 0}}> letterSpacing = 0 </Text> <Text style={{letterSpacing: 2, marginTop: 5}}> letterSpacing = 2 </Text> <Text style={{letterSpacing: 9, marginTop: 5}}> letterSpacing = 9 </Text> <Text style={{letterSpacing: -1, marginTop: 5}}> letterSpacing = -1 </Text> </View> ); }, }, { title: 'Spaces', render: function() { return ( <Text> A {'generated'} {' '} {'string'} and some spaces </Text> ); }, }, { title: 'Line Height', render: function() { return ( <Text> <Text style={{lineHeight: 35}}> A lot of space between the lines of this long passage that should wrap once. </Text> </Text> ); }, }, { title: 'Empty Text', description: 'It\'s ok to have Text with zero or null children.', render: function() { return ( <Text /> ); }, }, { title: 'Toggling Attributes', render: function(): ReactElement<any> { return <AttributeToggler />; }, }, { title: 'backgroundColor attribute', description: 'backgroundColor is inherited from all types of views.', render: function() { return ( <Text style={{backgroundColor: 'yellow'}}> Yellow container background, <Text style={{backgroundColor: '#ffaaaa'}}> {' '}red background, <Text style={{backgroundColor: '#aaaaff'}}> {' '}blue background, <Text> {' '}inherited blue background, <Text style={{backgroundColor: '#aaffaa'}}> {' '}nested green background. </Text> </Text> </Text> </Text> </Text> ); }, }, { title: 'numberOfLines attribute', render: function() { return ( <View> <Text numberOfLines={1}> Maximum of one line, no matter how much I write here. If I keep writing, it{"'"}ll just truncate after one line. </Text> <Text numberOfLines={2} style={{marginTop: 20}}> Maximum of two lines, no matter how much I write here. If I keep writing, it{"'"}ll just truncate after two lines. </Text> <Text style={{marginTop: 20}}> No maximum lines specified, no matter how much I write here. If I keep writing, it{"'"}ll just keep going and going. </Text> </View> ); }, }, { title: 'Text highlighting (tap the link to see highlight)', render: function() { return ( <View> <Text>Lorem ipsum dolor sit amet, <Text suppressHighlighting={false} style={{backgroundColor: 'white', textDecorationLine: 'underline', color: 'blue'}} onPress={() => null}>consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud</Text> exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</Text> </View> ); }, }, { title: 'allowFontScaling attribute', render: function() { return ( <View> <Text> By default, text will respect Text Size accessibility setting on iOS. It means that all font sizes will be increased or descreased depending on the value of Text Size setting in {" "}<Text style={{fontWeight: 'bold'}}>Settings.app - Display & Brightness - Text Size</Text> </Text> <Text style={{marginTop: 10}}> You can disable scaling for your Text component by passing {"\""}allowFontScaling={"{"}false{"}\""} prop. </Text> <Text allowFontScaling={false} style={{marginTop: 20}}> This text will not scale. </Text> </View> ); }, }, { title: 'Inline views', render: function() { return ( <View> <Text> This text contains an inline blue view <View style={{width: 25, height: 25, backgroundColor: 'steelblue'}} /> and an inline image <Image source={require('./flux.png')} style={{width: 30, height: 11, resizeMode: 'cover'}}/>. Neat, huh? </Text> </View> ); }, }, { title: 'Text shadow', render: function() { return ( <View> <Text style={{fontSize: 20, textShadowOffset: {width: 2, height: 2}, textShadowRadius: 1, textShadowColor: '#00cccc'}}> Demo text shadow </Text> </View> ); }, }]; var styles = StyleSheet.create({ backgroundColorText: { margin: 5, marginBottom: 0, backgroundColor: 'rgba(100, 100, 100, 0.3)' }, });
ANDROID |
Edit on GitHub |
'use strict'; var React = require('react'); var ReactNative = require('react-native'); var { Image, StyleSheet, Text, View, } = ReactNative; var UIExplorerBlock = require('./UIExplorerBlock'); var UIExplorerPage = require('./UIExplorerPage'); var Entity = React.createClass({ render: function() { return ( <Text style={{fontWeight: 'bold', color: '#527fe4'}}> {this.props.children} </Text> ); } }); var AttributeToggler = React.createClass({ getInitialState: function() { return {fontWeight: 'bold', fontSize: 15}; }, toggleWeight: function() { this.setState({ fontWeight: this.state.fontWeight === 'bold' ? 'normal' : 'bold' }); }, increaseSize: function() { this.setState({ fontSize: this.state.fontSize + 1 }); }, render: function() { var curStyle = {fontWeight: this.state.fontWeight, fontSize: this.state.fontSize}; return ( <View> <Text style={curStyle}> Tap the controls below to change attributes. </Text> <Text> <Text>See how it will even work on <Text style={curStyle}>this nested text</Text></Text> </Text> <Text> <Text onPress={this.toggleWeight}>Toggle Weight</Text> {' (with highlight onPress)'} </Text> <Text onPress={this.increaseSize} suppressHighlighting={true}> Increase Size (suppressHighlighting true) </Text> </View> ); } }); var TextExample = React.createClass({ statics: { title: '<Text>', description: 'Base component for rendering styled text.', }, render: function() { return ( <UIExplorerPage title="<Text>"> <UIExplorerBlock title="Wrap"> <Text> The text should wrap if it goes on multiple lines. See, this is going to the next line. </Text> </UIExplorerBlock> <UIExplorerBlock title="Padding"> <Text style={{padding: 10}}> This text is indented by 10px padding on all sides. </Text> </UIExplorerBlock> <UIExplorerBlock title="Font Family"> <Text style={{fontFamily: 'sans-serif'}}> Sans-Serif </Text> <Text style={{fontFamily: 'sans-serif', fontWeight: 'bold'}}> Sans-Serif Bold </Text> <Text style={{fontFamily: 'serif'}}> Serif </Text> <Text style={{fontFamily: 'serif', fontWeight: 'bold'}}> Serif Bold </Text> <Text style={{fontFamily: 'monospace'}}> Monospace </Text> <Text style={{fontFamily: 'monospace', fontWeight: 'bold'}}> Monospace Bold (After 5.0) </Text> </UIExplorerBlock> <UIExplorerBlock title="Android Material Design fonts"> <View style={{flexDirection: 'row', alignItems: 'flex-start'}}> <View style={{flex: 1}}> <Text style={{fontFamily: 'sans-serif'}}> Roboto Regular </Text> <Text style={{fontFamily: 'sans-serif', fontStyle: 'italic'}}> Roboto Italic </Text> <Text style={{fontFamily: 'sans-serif', fontWeight: 'bold'}}> Roboto Bold </Text> <Text style={{fontFamily: 'sans-serif', fontStyle: 'italic', fontWeight: 'bold'}}> Roboto Bold Italic </Text> <Text style={{fontFamily: 'sans-serif-light'}}> Roboto Light </Text> <Text style={{fontFamily: 'sans-serif-light', fontStyle: 'italic'}}> Roboto Light Italic </Text> <Text style={{fontFamily: 'sans-serif-thin'}}> Roboto Thin (After 4.2) </Text> <Text style={{fontFamily: 'sans-serif-thin', fontStyle: 'italic'}}> Roboto Thin Italic (After 4.2) </Text> <Text style={{fontFamily: 'sans-serif-condensed'}}> Roboto Condensed </Text> <Text style={{fontFamily: 'sans-serif-condensed', fontStyle: 'italic'}}> Roboto Condensed Italic </Text> <Text style={{fontFamily: 'sans-serif-condensed', fontWeight: 'bold'}}> Roboto Condensed Bold </Text> <Text style={{ fontFamily: 'sans-serif-condensed', fontStyle: 'italic', fontWeight: 'bold'}}> Roboto Condensed Bold Italic </Text> <Text style={{fontFamily: 'sans-serif-medium'}}> Roboto Medium (After 5.0) </Text> <Text style={{fontFamily: 'sans-serif-medium', fontStyle: 'italic'}}> Roboto Medium Italic (After 5.0) </Text> </View> </View> </UIExplorerBlock> <UIExplorerBlock title="Custom Fonts"> <View style={{flexDirection: 'row', alignItems: 'flex-start'}}> <View style={{flex: 1}}> <Text style={{fontFamily: 'notoserif'}}> NotoSerif Regular </Text> <Text style={{fontFamily: 'notoserif', fontStyle: 'italic', fontWeight: 'bold'}}> NotoSerif Bold Italic </Text> <Text style={{fontFamily: 'notoserif', fontStyle: 'italic'}}> NotoSerif Italic (Missing Font file) </Text> </View> </View> </UIExplorerBlock> <UIExplorerBlock title="Font Size"> <Text style={{fontSize: 23}}> Size 23 </Text> <Text style={{fontSize: 8}}> Size 8 </Text> </UIExplorerBlock> <UIExplorerBlock title="Color"> <Text style={{color: 'red'}}> Red color </Text> <Text style={{color: 'blue'}}> Blue color </Text> </UIExplorerBlock> <UIExplorerBlock title="Font Weight"> <Text style={{fontWeight: 'bold'}}> Move fast and be bold </Text> <Text style={{fontWeight: 'normal'}}> Move fast and be bold </Text> </UIExplorerBlock> <UIExplorerBlock title="Font Style"> <Text style={{fontStyle: 'italic'}}> Move fast and be bold </Text> <Text style={{fontStyle: 'normal'}}> Move fast and be bold </Text> </UIExplorerBlock> <UIExplorerBlock title="Font Style and Weight"> <Text style={{fontStyle: 'italic', fontWeight: 'bold'}}> Move fast and be bold </Text> </UIExplorerBlock> <UIExplorerBlock title="Text Decoration"> <Text style={{textDecorationLine: 'underline'}}> Solid underline </Text> <Text style={{textDecorationLine: 'none'}}> None textDecoration </Text> <Text style={{textDecorationLine: 'line-through', textDecorationStyle: 'solid'}}> Solid line-through </Text> <Text style={{textDecorationLine: 'underline line-through'}}> Both underline and line-through </Text> <Text> Mixed text with <Text style={{textDecorationLine: 'underline'}}>underline</Text> and <Text style={{textDecorationLine: 'line-through'}}>line-through</Text> text nodes </Text> </UIExplorerBlock> <UIExplorerBlock title="Nested"> <Text onPress={() => console.log('1st')}> (Normal text, <Text style={{fontWeight: 'bold'}} onPress={() => console.log('2nd')}> (and bold <Text style={{fontStyle: 'italic', fontSize: 11, color: '#527fe4'}} onPress={() => console.log('3rd')}> (and tiny bold italic blue <Text style={{fontWeight: 'normal', fontStyle: 'normal'}} onPress={() => console.log('4th')}> (and tiny normal blue) </Text> ) </Text> ) </Text> ) </Text> <Text style={{fontFamily: 'serif'}} onPress={() => console.log('1st')}> (Serif <Text style={{fontStyle: 'italic', fontWeight: 'bold'}} onPress={() => console.log('2nd')}> (Serif Bold Italic <Text style={{fontFamily: 'monospace', fontStyle: 'normal', fontWeight: 'normal'}} onPress={() => console.log('3rd')}> (Monospace Normal <Text style={{fontFamily: 'sans-serif', fontWeight: 'bold'}} onPress={() => console.log('4th')}> (Sans-Serif Bold <Text style={{fontWeight: 'normal'}} onPress={() => console.log('5th')}> (and Sans-Serif Normal) </Text> ) </Text> ) </Text> ) </Text> ) </Text> <Text style={{fontSize: 12}}> <Entity>Entity Name</Entity> </Text> </UIExplorerBlock> <UIExplorerBlock title="Text Align"> <Text> auto (default) - english LTR </Text> <Text> أحب اللغة العربية auto (default) - arabic RTL </Text> <Text style={{textAlign: 'left'}}> left left left left left left left left left left left left left left left </Text> <Text style={{textAlign: 'center'}}> center center center center center center center center center center center </Text> <Text style={{textAlign: 'right'}}> right right right right right right right right right right right right right </Text> </UIExplorerBlock> <UIExplorerBlock title="Unicode"> <View style={{flex: 1}}> <View style={{flexDirection: 'row'}}> <Text style={{backgroundColor: 'red'}}> 星际争霸是世界上最好的游戏。 </Text> </View> <View style={{flex: 1}}> <Text style={{backgroundColor: 'red'}}> 星际争霸是世界上最好的游戏。 </Text> </View> <View style={{flex: 1, alignItems: 'center'}}> <Text style={{backgroundColor: 'red'}}> 星际争霸是世界上最好的游戏。 </Text> </View> <View style={{flex: 1}}> <Text style={{backgroundColor: 'red'}}> 星际争霸是世界上最好的游戏。星际争霸是世界上最好的游戏。星际争霸是世界上最好的游戏。星际争霸是世界上最好的游戏。 </Text> </View> </View> </UIExplorerBlock> <UIExplorerBlock title="Spaces"> <Text> A {'generated'} {' '} {'string'} and some spaces </Text> </UIExplorerBlock> <UIExplorerBlock title="Line Height"> <Text style={{lineHeight: 35}}> Holisticly formulate inexpensive ideas before best-of-breed benefits. <Text style={{fontSize: 20}}>Continually</Text> expedite magnetic potentialities rather than client-focused interfaces. </Text> </UIExplorerBlock> <UIExplorerBlock title="Empty Text"> <Text /> </UIExplorerBlock> <UIExplorerBlock title="Toggling Attributes"> <AttributeToggler /> </UIExplorerBlock> <UIExplorerBlock title="backgroundColor attribute"> <Text style={{backgroundColor: '#ffaaaa'}}> Red background, <Text style={{backgroundColor: '#aaaaff'}}> {' '}blue background, <Text> {' '}inherited blue background, <Text style={{backgroundColor: '#aaffaa'}}> {' '}nested green background. </Text> </Text> </Text> </Text> <Text style={{backgroundColor: 'rgba(100, 100, 100, 0.3)'}}> Same alpha as background, <Text> Inherited alpha from background, <Text style={{backgroundColor: 'rgba(100, 100, 100, 0.3)'}}> Reapply alpha </Text> </Text> </Text> </UIExplorerBlock> <UIExplorerBlock title="containerBackgroundColor attribute"> <View style={{flexDirection: 'row', height: 85}}> <View style={{backgroundColor: '#ffaaaa', width: 150}} /> <View style={{backgroundColor: '#aaaaff', width: 150}} /> </View> <Text style={[styles.backgroundColorText, {top: -80}]}> Default containerBackgroundColor (inherited) + backgroundColor wash </Text> <Text style={[styles.backgroundColorText, {top: -70, backgroundColor: 'transparent'}]}> {"containerBackgroundColor: 'transparent' + backgroundColor wash"} </Text> </UIExplorerBlock> <UIExplorerBlock title="numberOfLines attribute"> <Text numberOfLines={1}> Maximum of one line no matter now much I write here. If I keep writing it{"'"}ll just truncate after one line </Text> <Text numberOfLines={2} style={{marginTop: 20}}> Maximum of two lines no matter now much I write here. If I keep writing it{"'"}ll just truncate after two lines </Text> <Text style={{marginTop: 20}}> No maximum lines specified no matter now much I write here. If I keep writing it{"'"}ll just keep going and going </Text> </UIExplorerBlock> <UIExplorerBlock title="Inline images"> <Text> This text contains an inline image <Image source={require('./flux.png')}/>. Neat, huh? </Text> </UIExplorerBlock> <UIExplorerBlock title="Text shadow"> <Text style={{fontSize: 20, textShadowOffset: {width: 2, height: 2}, textShadowRadius: 1, textShadowColor: '#00cccc'}}> Demo text shadow </Text> </UIExplorerBlock> </UIExplorerPage> ); } }); var styles = StyleSheet.create({ backgroundColorText: { left: 5, backgroundColor: 'rgba(100, 100, 100, 0.3)' }, }); module.exports = TextExample;