Since there is no "align-items: baseline" in RN's implementation of Flexbox, how can I align the baselines of two text element horizontally?
The JSX:
<View style={styles.numberAndPercent}>
<Text style={styles.number}>6.80</Text>
<Text style={styles.percent}>%</Text>
</View>
Syntax: alignItems: stretch|center|flex-start|flex-end|baseline; Property Values: stretch: It is the default value of alignItems.
Use textAlign: 'right' on the Text element (This approach doesn't change the fact that the Text fills the entire width of the View ; it just right-aligns the text within the Text .)
React Native now supports alignItems: 'baseline'
, so the following should work:
numberAndPercent: {
flexDirection: 'row',
alignItems: 'baseline',
}
Flexbox docs here; full list of supported values here.
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