MotionScript

@motion-script/core


@motion-script/core / applyTextDefaults

Function: applyTextDefaults()

applyTextDefaults(node, props?): void

Defined in: runtime/builtin-context.ts:118

Apply text-style defaults to a text node, for each style key the author didn't pass explicitly. Shared by Text and RichText's init.

Precedence per key, highest to lowest:

  1. explicit author prop (present in props) — never overridden;
  2. the node's variant typography preset, from theme.typography (registered by setTheme, looked up via getTypographyPreset);
  3. the inherited TextStyleToken default from an ancestor <DefaultTextStyle>;
  4. the theme's default typography preset (theme.typography.default) — a project-wide base style applied with no variant or <DefaultTextStyle> required; (5. the node's own @property default — already applied by the constructor.)

Assignment goes through the node's property setter, which runs the field's registered mapper (so a preset/inherited fill: 'brand-500' is resolved exactly as if the author had written it). props is the node's own constructor props.

Parameters

node

Node

props?

Record<string, unknown>

Returns

void