# fitContent

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

`fitContent(limit)` returns a frozen, branded [`FitContent`](/reference/types/layout/#fitcontent)
value used by [`SizingLength`](/reference/types/layout/#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`](/reference/types/layout/#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.

## API details from source

<span id="api-fitContent"></span>

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

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

Related API: [fitContent](/reference/functions/fit-content/), [Percentage](/reference/types/layout/#percentage), [FitContent](/reference/types/layout/#fitcontent).

### Parameters

- **`limit`** — Nonnegative finite logical width or parent-axis [Percentage](/reference/types/layout/#percentage).

### Returns

Branded immutable [FitContent](/reference/types/layout/#fitcontent) sizing value.

### See also

[SizingLength](/reference/types/layout/#sizinglength)

[View source — packages/core/src/lib/style/sizing-length.ts:43](/source/packages/core/src/lib/style/sizing-length-ts/#L43)

## Implementation guidance for agents

Read the [Authoring, signals, and lifecycle companion](/agents/topics/lifecycle/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Intrinsic sizing contracts](/minimal-examples/layout/intrinsic-types/): Typecheck paired intrinsic sizes, baseline results, and fit-content sizing values. [Plain source](/minimal/layout/intrinsic-types.ts)
## Documentation version

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