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 Icon

Previous
Customize Tree
Next
Customize Cell Alignment

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...

By default, S2 will display the default intra-group sorting operation icon at the index row header (indicator hanging row header) or column header (indicator hanging column header), as shown in the following figure:

preview

But in many cases, you will need to display other action icon , such as: filter, drill down, etc. S2 provides the headerActionIcons parameter so that you can quickly customize the action icon of the row header, column header, and corner header through simple configuration items.

const s2Options = {
headerActionIcons: [
{
icons: ['SortDown'],
belongsCell: 'colCell',
},
],
}

1. If the built-in icon is not satisfied, you can configure customSVGIcons parameter to additionally register your own icon . The custom icon is also applicable to the theme configuration , which means that you can also adjust its size and color. For details, please refer to the theme configuration chapter.

const s2Options = {
customSVGIcons: [
{
name: 'Filter',
src: 'https://gw.alipayobjects.com/zos/antfincdn/gu1Fsz3fw0/filter%26sort_filter.svg',
},
],
}

Or override the default icon , such as a custom tree form to collapse and expand the icon

const s2Options = {
customSVGIcons: [
{
name: 'Plus',
src: 'https://gw.alipayobjects.com/zos/antfincdn/kXgP1pnClS/plus.svg',
},
{
name: 'Minus',
src: 'https://gw.alipayobjects.com/zos/antfincdn/2aWYZ7%26rQF/minus-circle.svg',
},
],
}

S2 currently has a list of built-in icons:

icon nameicon iconFunctional descriptionicon nameicon iconFunctional description
Cell DowniconYoY declineExpandColIconiconSchedule HideExpand
CellUpiconYoY risePlusicontree form expansion
GlobalAsciconglobal ascendingMinusiconTree form collapsed
GlobalDesciconglobal descendingSortDowniconSchedule descending
GroupAsciconascending order within groupSortDownSelectediconSchedule descending selection status
GroupDescicondescending order within groupSortUpiconSchedule Ascending
trendiconTrendSortUpSelectediconSchedule ascending selection status
ArrowUpiconindicator risesArrowDowniconindicators drop
DrillDownIconicondrill down

​

2. Configure headerActionIcons parameter ​ ⚠️ Note: To register a custom row and column header action icon, you need to set the showDefaultHeaderActionIcon of options to false first, otherwise the sorting icon displayed in the indicator column header by default will not disappear

configuration parameters


HeaderActionIcon

optional object

Function description: Register a custom operation icon for the row, column, and corner headers of the table.

parameterillustratetypeDefaultsrequiredvalueVersion
iconNamesThe name of the registered icon, or the name of the icon registered by the user through customSVGIconsstring[]✓
belongs to CellThe name of the cell that needs to add an operation iconstring[]✓Corner header: 'cornerCell';
column header: 'colCell';
row header: 'rowCell'
defaultHideControl whether the icon is displayed only when hover`boolean(meta: Node, iconName: string) => boolean`falsetrue
displayConditionDisplay filter conditions, user-defined which levels or cells need to display icons through this callback function. All icons that return true will be shown to the user.(mete: Node, iconName: string) => boolean;1.26.0 returns the iconName and presses a single icon to control the display and hiding
onClickExecution function after icon click(headerIconClickParams: HeaderIconClickParams) => void;1.26.0
onHoverThe execution function after the icon hover starts and ends(headerIconHoverParams: HeaderIconHoverParams) => void;1.26.0

​

HeaderActionIconProps

required object

Function description: After clicking the custom operation icon, the pivot table returns information related to the current icon

parameterFunctional descriptiontypeDefaultsrequired
iconNameThe name of the currently clicked iconstring✓
metaThe meta information of the current cellnode✓
eventCurrent click event informationeventfalse✓

CustomSVGIcon

optional object

Function description: used for users to register their own icons, currently only supports svg format

parameterillustratetypeDefaultsrequired
nameicon namestring-✓
svgThree formats of svg strings are currently supported:
1. base 64
2. svg local file
3. Online picture address
string-✓

Custom row and column header icon example

Custom cell icon example

For details on cell marking, see the field marking chapter

const s2Options = {
customSVGIcons: [
{
name: 'Filter',
src: 'https://gw.alipayobjects.com/zos/antfincdn/gu1Fsz3fw0/filter%26sort_filter.svg',
},
],
conditions: {
icon: [
{
field: 'number',
mapping(fieldValue, data) {
return {
// 使用自定义 icon 名称
icon: 'Filter',
fill: '#30BF78',
};
},
},
],
},
}