Surprisingly there isn't one question that groups these all together yet on Stack Overflow; there hasn't been an answer on SO for italics or underline, in fact, only this question for bold. I self-answered this quesiton below.
Use inline styles to bold specific text in React. js, e.g. <span style={{fontWeight: 'bold'}}>world</span> . The bold font will only be applied to the element to which it was added and its children. Copied!
In react native we can create underline text using textDecorationLine: 'underline' style prop. This prop works on both Android and iOS platforms.
Click the Bold button on the Formatting toolbar (Ctrl+B). Click the Italic button on the Formatting toolbar (Ctrl+I). Click the Underline button on the Formatting toolbar (Ctrl+U).
<Text style={styles.bold}>I'm bold!</Text> <Text style={styles.italic}>I'm italic!</Text> <Text style={styles.underline}>I'm underlined!</Text> const styles = StyleSheet.create({ bold: {fontWeight: 'bold'}, italic: {fontStyle: 'italic'}, underline: {textDecorationLine: 'underline'} })
Working demo on Snack: https://snack.expo.io/BJT2ss_y7
<View style={styles.MainContainer}> <Text style={styles.TextStyle}>Example of Underline Text</Text> </View>
TextStyle: { textAlign: 'center', fontWeight: 'bold' fontStyle: 'italic' fontSize: 20, textDecorationLine: 'underline', //line-through is the trick },
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With