Skip to content

align

The place of the cells’ text, and of the title by default.

Type'start' | 'center' | 'end'
Default'end' for a number column, else 'start'
Live update (update())Yes — give the columns again (update({ columns }))
Declared inpackages/core/src/columns/defs.ts

'start', 'center' or 'end', logical sides: in right-to-left, 'end' is the left. A number column sits at the end so its digits line up; every other type at the start. The header’s title follows unless headerAlign says otherwise.

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' },
{ id: 'shelf', header: 'Shelf', type: 'number', align: 'center' },
],
getRowId: (r) => r.id,
messages: EN,
});