logo

S2

  • Manual
  • API
  • Examples
  • Playground
  • ChangeLog
  • Productsantv logo arrow
  • 2.x
  • Introduction
  • Quick Start
  • Basic Tutorial
    • Base Concept
    • Sheet Type
      • Pivot Mode
        Updated
      • Table Mode
    • Conditions
      Updated
    • Totals
    • Sort
      • Custom Sort
        Updated
      • Group Sort
        Updated
    • Theme
      Updated
    • Tooltip
      Updated
    • Internationalization
    • 数据格式化
      New
    • Multi Line
      New
    • Pagination
      New
  • Advanced Tutorial
    • Advanced Tutorial
      • Link
      • Render Chart In Cell
      • Draw Chart With @antv/g2
    • Custom
      • Customize Hook
        Updated
      • Customize Tree
        New
      • Customize Icon
      • Customize Cell Alignment
      • Customize Cell Size
        Updated
      • Customize Order
      • Custom Collapse/Expand Nodes
    • Interaction
      • Basic Interaction
      • Custom Interaction
      • Hide Columns
      • Cell Resize
      • Merge Cell
      • Scroll
      • Copy
        New
      • Highlight and select cell
        New
    • Analyze Component
      • Introduction
        New
      • Advanced Sort
        Updated
      • Switcher
      • Export
        Updated
      • Pagination
      • Drill Down
    • Sheet Component
      • Editable Mode
      • Strategy Sheet
        Updated
    • HD Adapter
    • Get Instance
    • Get Cell Data
      Updated
    • Table adaptive
    • AntV/G Plugins
      New
    • Pivot Chart
      Experimental
    • Vue 3.0
  • Extended Reading
    • Data Process
      • Pivot
      • Table
    • Layout
      • Pivot
      • Table
    • Performance
      Updated
  • Contribution
  • FAQ
  • S2 2.0 Migration Guide

Customize Cell Alignment

Previous
Customize Icon
Next
Customize Cell Size

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Before reading this section, please make sure you have read the theme configuration documentation

In order to facilitate users to view data, S2 crosstab will ensure the maximum visibility of row and column headers during the sliding process

img

Therefore, S2 has certain restrictions on the alignment of cells. The alignment behaviors that can be customized for each type of cell are introduced below.

Corner Alignment

  • The alignment of row header cells (red part) is controlled by bolderText
  • The alignment of the column header cell (blue part) is controlled by text

img

The textBaseline of the corner header is internally specified as middle , so only textAlign can be customized. The following are the display forms of the three alignment methods:

cornerCell: {
 text: {
 textAlign: 'left',
 },
 bolderText: {
 textAlign: 'left',
 }
}
left
cornerCell: {
 text: {
 textAlign: 'center',
 },
 bolderText: {
 textAlign: 'center',
 }
}
center
cornerCell: {
 text: {
 textAlign: 'right',
 },
 bolderText: {
 textAlign: 'right',
 }
}
right

line header alignment

  • The alignment of non-leaf nodes and subtotal cells (red parts) is controlled by bolderText
  • The alignment of leaf node cells (blue part) is controlled by text
  • The serial number cell can be controlled separately, and it is aligned with the row header by default, and the alignment is controlled by seriesText

img

Due to the feature of sliding and centering, the textBaseline of the line header is internally specified as top , so only textAlign can be customized. The following are the display forms of the three alignment methods:

 rowCell: {
 text: {
 textAlign: 'left',
 },
 bolderText: {
 textAlign: 'left',
 }
}
left
 rowCell: {
 text: {
 textAlign: 'center',
 },
 bolderText: {
 textAlign: 'center',
 }
}
center
 rowCell: {
 text: {
 textAlign: 'right',
 },
 bolderText: {
 textAlign: 'right',
 }
}
right

column header alignment

In order to ensure the maximum visibility under sliding, the textBaseline of the non-leaf node cells in the column head is internally specified as middle , and the textAlign is unlimited and can be customized as needed.

  • The alignment of the indicator cell (red part) is controlled by bolderText
  • The alignment of other dimension cells (blue part) is controlled by measureText (by default, it is aligned with the data cell)
col cell align desc

The effects of the three alignment methods of the column header cells are as follows:

colCell: {
 measureText: {
 textAlign: 'left',
 },
 bolderText: {
 textAlign: 'left',
 }
}
left
colCell: {
 measureText: {
 textAlign: 'center',
 },
 bolderText: {
 textAlign: 'center',
 }
}
center
colCell: {
 measureText: {
 textAlign: 'right',
 },
 bolderText: {
 textAlign: 'right',
 }
}
right

Data Cell Alignment

  • The alignment of subtotal total cell (red part) is controlled by bolderText
  • The alignment of other node cells (blue parts) is controlled by text

img

The data cell textBaseline and textAlign are unlimited and can be customized:

dataCell: {
 text: {
 textAlign: 'left',
 textBaseline: 'top',
 },
 bolderText: {
 textAlign: 'left',
 textBaseline: 'top',
 }
}
left
dataCell: {
 text: {
 textAlign: 'center',
 textBaseline: 'middle',
 },
 bolderText: {
 textAlign: 'center',
 textBaseline: 'middle',
 }
}
center
dataCell: {
 text: {
 textAlign: 'right',
 textBaseline: 'bottom',
 },
 bolderText: {
 textAlign: 'right',
 textBaseline: 'bottom',
 }
}
right

Customize specific cell alignment

Sometimes we want to achieve an effect similar to字段标记, and自定义对齐方式of specific cells that meet the conditions , instead of changing everything. At this time, we can自定义单元格, dataCell , colCell , rowCell , etc. provided by S2 Hook to do customization.