Skip to content

fitContent

Read as Markdown

import { fitContent } from "@pibbl/core";
const basis = fitContent(80);

fitContent(limit) returns a frozen, branded FitContent value used by SizingLength. The limit is a finite nonnegative number or percentage of the finite parent main axis. The selected content width is min(maxContent.width, max(minContent.width, limit)); min-content may exceed the limit. Explicit numeric maximum bounds remain hard clamps during allocation.

In the default native layout engine, direct paired-measurable children of finite horizontal nowrap Flex owners, and built-in Canvas Text in those owners, can use this value as width or flexBasis. A non-auto flex basis takes precedence over width. Existing growth, shrinkage and numeric bounds apply after the intrinsic basis is selected. Final cross size uses measurement at the allocated width, rather than a paired intrinsic height.

Text derives min-content from its existing space-separated word policy when wrapping, and max-content from its natural Canvas run. Unwrapped runs retain leading spaces and have equal min/max contributions. Final line height is measured at the allocated width.

Intrinsic values require an admitted measuring owner. Other owners, vertical intrinsic sizing, stretch, and intrinsic min/max bounds are not implemented by the current owner and raise structured layout diagnostics. Padding, positions and gaps still use scalar Length.

Border-box intrinsic requests retain the same content limit. Padding and layout borders are added once after the content contribution is selected; numeric minWidth/maxWidth still describe outer bounds. For example, limit80 with16px of horizontal insets and maxWidth: 90 yields74px content and90px outer width. Limit60 yields60px content and76px outer width. A limit below min-content cannot remove the content floor. Intrinsic height and intrinsic bounds remain unsupported.

Creates an immutable bound between measured min- and max-content widths.

fitContent: (limit: number | Percentage) => FitContent

Related API: fitContent, Percentage, FitContent.

  • limit — Nonnegative finite logical width or parent-axis Percentage.

Branded immutable FitContent sizing value.

SizingLength

View source — packages/core/src/lib/style/sizing-length.ts:43

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 a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.