JavaScript Data Grid Text alignment

Align values within cells: horizontally (to the right, left, center, or by justifying them), and vertically (to the top, middle, or bottom of the cell).

Horizontal and vertical alignment

To initialize Handsontable with predefined horizontal and vertical alignment globally, provide the alignment details in the className option, for example:

className: 'htCenter'

Cells can be also configured individually by setting up the cells option. See the code sample below for an example.

Available class names:

  • Horizontal: htLeft, htCenter, htRight, htJustify,
  • Vertical: htTop, htMiddle, htBottom.

Alignment changes can be tracked using the afterSetCellMeta hook.

Basic example

The following code sample configures the grid to use htCenter and configures individual cells to use different alignments.