I would like to style text as superscript in React Native. How would this be accomplished? Is there a way to make use of the Javascript sup()
string method to return a string as superscript within a <Text>
object?
The <sup> tag defines superscript text. Superscript text appears half a character above the normal line, and is sometimes rendered in a smaller font. Superscript text can be used for footnotes, like WWW. Tip: Use the <sub> tag to define subscript text.
Subscripts are often used to refer to members of a mathematical sequence or set or elements of a vector. For example, in the sequence O = (45, −2, 800), O3 refers to the third member of sequence O, which is 800.
Subscript: The <sub> tag is used to add a subscript text to the HTML document. The <sub> tag defines the subscript text. Subscript text appears half a character below the normal line and is sometimes rendered in a smaller font.
I got this working for me using a view container and flex.
<View style={{flexDirection: 'row', alignItems: 'flex-start'}}>
<Text style={{fontSize: 20, lineHeight: 30}}>10</Text>
<Text style={{fontSize: 11, lineHeight: 18}}>am</Text>
</View>
Here is the link to this in action https://repl.it/Haap/0
Cheers!
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