Skip to content

minWidth

A floor under the column’s width.

Typenumber
Default40
Live update (update())Yes — give the columns again (update({ columns }))
Declared inpackages/core/src/columns/defs.ts

No width goes under it: not the definition’s, not the user’s drag, not the menu’s « Narrow », not a flex share when the grid is narrow (the grid scrolls sideways instead). It is 40 px when not given, or 80 px when the column’s header has a filter button: the button, the resize grip and the start of the title fit side by side, on one line. A minWidth you give wins, smaller too. Give a flexible column a minWidth, so it never gets too narrow to read.

With collapsePriority, a flexible column counts its minWidth to decide whether it fits. A value that is not a number of zero or more is refused with an invalid-column error.

import { createGrid } from '@dzgrid/dom';
import { EN } from '@dzgrid/dom/locales/en';
type Tool = { id: string; name: string; shelf: number; notes: string };
createGrid<Tool>(document.getElementById('tools')!, {
rows: [{ id: 't1', name: 'Hammer', shelf: 2, notes: 'Claw, 450 g' }],
columns: [
{ id: 'name', header: 'Tool', flex: 1, minWidth: 140 },
{ id: 'notes', header: 'Notes', flex: 2, minWidth: 200 },
],
getRowId: (r) => r.id,
messages: EN,
});