Textual
Paragraphs#
Paragraphs have a default top and bottom margin. If you use โenableExperimentalMarginCollapsing prop, margins of adjacents blocks will collapse as per the CSS standard.
- JSX Source
- HTML Snippet
- TRT Snapshot
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 Collapsing#
White 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>.
- JSX Source
- HTML Snippet
- TRT Snapshot
Example: 'white-space: pre'#
You can set the โwhite-space CSS property with inline styles or with classes, id and tags styles.
- JSX Source
- HTML Snippet
- TRT Snapshot
Preformatted Content#
- JSX Source
- HTML Snippet
- TRT Snapshot
note
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 Selection#
CSS โ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#
- JSX Source
- HTML Snippet
- TRT Snapshot
Example: Courier New Font Selection#
- JSX Source
- HTML Snippet
- TRT Snapshot
Example: Space Mono Font Selection#
- JSX Source
- HTML Snippet
- TRT Snapshot
caution
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 Breaks#
Line 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:
- JSX Source
- HTML Snippet
- TRT Snapshot
Hopefully, the bug has been identified and since version 6.1.1 there is a workaround. You just need to pass โenableExperimentalBRCollapsing prop:
- JSX Source
- HTML Snippet
- TRT Snapshot
Empty Tags#
React Native has a weird behavior whereby empty โText elements span vertically on iOS and Android. I called this "ghost lines". For example:
- JSX Source
- HTML Snippet
- TRT Snapshot
Since version 6.1.1, a new prop, โenableExperimentalGhostLinesPrevention, prevent this behavior from happening. It will also handle multiple ghost elements:
- JSX Source
- HTML Snippet
- TRT Snapshot