For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/styling/inheritance.md.

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.

<!-- color on the view doesn't reach the text -->
<view style="color: white">
  <text>Not white</text>
</view>

<!-- set it on the text itself -->
<view>
  <text style="color: white">White</text>
</view>
  • 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-size inherits. 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" at text-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>'s color and font-family, as well as its font-size.
  • CSS variables always inherit, as on the web. Set them on a parent and use var() anywhere below it.
  • There's no inherit, initial or unset keyword.

HTML text tags

<view class="text-red-500">
  <p>Red, as on the web</p>
  <div>Loose text is red too</div>
</view>

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 enableCSSInheritance turns on, below.
  • Renderer internals explains how.
Which rules count
  • A rule naming text isn't a <p>'s own. A <p> renders as a <text>, so the UI theme's view > text matches 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 > b styles 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 style or [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
import { defineConfig, pluginAngularLynx } from '@blotch/angular-lynx-build';

export default defineConfig({
  plugins: [pluginAngularLynx({ enableCSSInheritance: true })],
});

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 customCSSInheritanceList instead. It's ['font-size'] by default.
  • enableCSSInheritance: false turns off font-size too. A <text> with no size then takes the page's.
  • Both are in the plugin options on the @blotch/angular-lynx-build page.