Textual
#
ParagraphsParagraphs have a default top and bottom margin. If you use ​enableExperimentalMarginCollapsing
prop, margins of adjacents blocks will collapse as per the CSS standard.
caution
​enableExperimentalMarginCollapsing
is considered experimental because the ​TRE doesn't support ​display
CSS property yet. However, margin collapsing should not apply to flex layouts while this prop will apply margin collapsing indiscriminately.
#
Whitespace CollapsingWhite space collasping occurs in the eponym phase of the ​Transient Render Engine processing step. Insignificant whitespaces are removed from the tree, as per the algorithm depicted in CSS Text Module Level 3.
note
The ​TRE strictly complies with this standard, although only white-space: normal;
and white-space:Â pre;
are supported at the moment.
#
Example: 'white-space: normal'This is the default behavior, with the exception of a handful of tags such as ​<pre>
.
#
Example: 'white-space: pre'You can set the ​white-space
CSS property with inline styles or with classes, id and tags styles.
#
Preformatted Contentnote
The default font for the ​<pre>
tag is monospace and ​white-space
property is "pre". These default styles are set via the ​mixedUAStyles
associated with this tag element model. See ​Element Models.
#
Font SelectionCSS ​font-family
and ​font
properties allow a comma-separated list of fonts, but React Native styles fontFamily
allows only one font name. With the ​TRE, you can instruct which fonts are available in the system (or fonts you have added), and it will pick the first match! The prop to achieve that is ​systemFonts
.
By default, a handful of fonts supported by the current platform are pre-registered (Android, iOS, MacOS and Windows). If you are using expo, just set this prop to Constants.systemFonts. You can also define how generic font names are resolved with the ​fallbackFonts
prop.
#
Example: Arial Font Selection#
Example: Courier New Font Selection#
Example: Space Mono Font Selectioncaution
Fonts registered in ​systemFonts
should not be surrounded with quotes; however you can surround the font name with quotes in inline and mixed styles, as per CSS standard.
#
Caveats#
Line BreaksLine breaks work seemlessly with the ​<br>
element. There is a known bug though in the Foundry release, where line breaks closing an inline formatting context will be printed while they should be ignored. Below is an example for illustration purposes:
Hopefully, the bug has been identified and since version 6.1.1 there is a workaround. You just need to pass ​enableExperimentalBRCollapsing
prop:
#
Empty TagsReact Native has a weird behavior whereby empty ​Text
elements span vertically on iOS and Android. I called this "ghost lines". For example:
Since version 6.1.1, a new prop, ​enableExperimentalGhostLinesPrevention
, prevent this behavior from happening. It will also handle multiple ghost elements: