Skip to content

resolveLength

Read as Markdown

import { resolveLength } from "@pibbl/core";

resolveLength(value, reference, property, context?) resolves a public Length and returns a finite logical number or undefined for "auto". Numeric values must be finite; percentages need a definite nonnegative reference. Invalid input produces a contextual LayoutDiagnostic.

const width = resolveLength("50%", 320, "width"); // 160

See Style and draw for local style usage.

Resolves a numeric or percentage length; automatic sizing returns undefined.

resolveLength: (value: Length, reference: number | undefined, property: string, context?: Readonly<LayoutDiagnosticContext>) => number | undefined

Related API: resolveLength, Length, LayoutDiagnosticContext.

  • value — Logical length or percentage to resolve. See Length.

  • reference — Reference length for percentages, or undefined if unavailable.

  • property — Property name used in diagnostics.

  • context — Component and property context for diagnostic messages. See LayoutDiagnosticContext .

The resolved logical length, or undefined for an unresolved automatic length.

Length

LayoutDiagnosticContext

View source — packages/core/src/lib/style/resolve-length.ts:22

Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.