Skip to content

density

How tall the rows are, and how much room the cells take on their sides.

Type'compact' | 'comfortable' | 'spacious'
Default'comfortable'
Live update (update())Yes
Angularthe [density] input
<dz-grid>the density attribute
Declared inpackages/dom/src/settings.ts

'compact', 'comfortable' (the default) or 'spacious': a row is 28, 32 or 40 px tall at a 16 px text size, and taller when the reader makes the text bigger. The header rows follow, unless headerHeight sets them. The cells’ side padding follows too: the grid’s own CSS sets --dzg-density on its root (.75, 1, 1.25), and the padding is multiplied by it; .dzg { --dzg-density: 1 } in your own CSS keeps it fixed.

rowHeight sets the rows in pixels and wins over the density’s height; the padding still follows the density. The column menu can offer the density to the user (columnMenu({ density: true }), not while rowHeight is set), and the state keeps it.

import { createGrid } from '@dzgrid/dom';
import { EN } from '@dzgrid/dom/locales/en';
type Kite = { id: string; name: string; span: number };
const grid = createGrid<Kite>(document.getElementById('kites')!, {
rows: [{ id: 'k1', name: 'Red delta', span: 1.6 }],
columns: [{ id: 'name', header: 'Kite' }, { id: 'span', header: 'Span (m)', type: 'number' }],
getRowId: (k) => k.id,
messages: EN,
density: 'compact',
});
grid.update({ density: 'spacious' });

Compact: rows 28 px tall, narrower side padding.