Text inheritance
On Lynx, most CSS properties don't inherit. Put text styles on the <text> itself, or turn inheritance on for the properties you need.
- CSS properties don't inherit by default, except
font-size. Each element gets only the rules that match it. Inheritance has a performance cost, so Lynx leaves it off. font-sizeinherits. A<text>with no size of its own takes its parent's, as on the web.<view class="text-xl"><text>Hi</text></view>draws "Hi" attext-xl. With no sized ancestor, it takes the page's.- HTML text tags and loose text do inherit, as on the web. See HTML text tags.
- A nested
<text>takes more. An inner<text>takes its parent<text>'scolorandfont-family, as well as itsfont-size. - CSS variables always inherit, as on the web. Set them on a parent and use
var()anywhere below it. - There's no
inherit,initialorunsetkeyword.
HTML text tags
A <p>, <span> or <h1> inherits text styles, and so does text written straight in a <view> or <div>.
- Each takes the text properties its own rules don't set from the nearest ancestor that sets them.
- The properties are the ones
enableCSSInheritanceturns on, below. - Renderer internals explains how.
Which rules count
- A rule naming
textisn't a<p>'s own. A<p>renders as a<text>, so the UI theme'sview > textmatches it on Lynx. But a<p>in a<view class="text-red-500">is still red, as on the web. One with no colored ancestor takes the page's color, which the theme sets. - A rule that needs an ancestor counts only where the tag has it.
.card b { font-size: 24px }sizes a<b>inside.card. A<b>elsewhere takes the size of the text around it. - A child combinator reaches an inline tag beside loose text.
.row > bstyles the<b>in<div class="row">Total: <b>12</b></div>. That works even though the runtime draws "Total: " and the<b>in a<text>of their own, between the<div>and the<b>. The build gives the rule a second selector through that<text>. - An inline style passes styles down too. An inline
styleor[style.x]binding counts as a rule does.<text style="font-size: 18px">Total: <b>12</b></text>draws the<b>at 18px.<div style="color: red">colors the<p>inside it.
- An HTML tag inside a Lynx
<text>follows that<text>. It reads only what the<text>'s rules or inline style set, or those of an HTML tag between them. Any other property, it draws as the<text>does.<text>Total: <b>12</b></text>draws the<b>at the size of "Total:".
Inherit every text property
To make every text property inherit as on the web, turn on enableCSSInheritance in a lynx.config.ts at the project root:
lynx.config.ts
These then inherit: color, direction, font-family, font-size, font-style, font-weight, letter-spacing, line-height, text-align, text-decoration and text-shadow.
- To pick the list yourself, pass
customCSSInheritanceListinstead. It's['font-size']by default. enableCSSInheritance: falseturns offfont-sizetoo. A<text>with no size then takes the page's.- Both are in the plugin options on the
@blotch/angular-lynx-buildpage.
