# fitColumnWidths (@salmonui/data-grid/engine)

> The fitColumnWidths function of @salmonui/data-grid/engine: Expands column widths proportionally so that their sum reaches target. Columns are never shrunk: when the widths already reach target the input widths are returned unchanged and the grid scrolls horizontally. Flexible columns grow in proportion to their width, capped at max; the result is whole px and sums to target unless every flexible column is capped. Returns null when nothing changes.

Canonical: https://salmonui.dev/docs/reference/data-grid/engine/fitColumnWidths

```ts
import { fitColumnWidths } from '@salmonui/data-grid/engine';
```

Entry index: https://salmonui.dev/docs/reference/data-grid/engine (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data-grid/engine.md).

## Reference

Kind: function

```ts
function fitColumnWidths(columns: readonly FitColumn[], target: number): number[] | null;
```

Expands column widths proportionally so that their sum reaches `target`.
Columns are never shrunk: when
the widths already reach `target` the input widths are returned unchanged
and the grid scrolls horizontally. Flexible columns grow in proportion to
their width, capped at `max`; the result is whole px and sums to `target`
unless every flexible column is capped. Returns `null` when nothing changes.
