Table

A table displays rows of data.
Importimport{ Table }from"antd";

When To Use

  • To display a collection of structured data.
  • To sort, search, paginate, filter data.

How To Use

Specify dataSource of Table as an array of data.

const dataSource = [
{
key: '1',
name: 'Mike',
age: 32,
address: '10 Downing Street',
},
{
key: '2',
name: 'John',
age: 42,
address: '10 Downing Street',
},
];
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
{
title: 'Address',
dataIndex: 'address',
key: 'address',
},
];
<Table dataSource={dataSource} columns={columns} />;

Promotion

Examples

NameAgeAddressTagsAction
John Brown32New York No. 1 Lake ParkNICEDEVELOPER
Jim Green42London No. 1 Lake ParkLOSER
Joe Black32Sydney No. 1 Lake ParkCOOLTEACHER

Simple table with actions.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddressTagsAction
First NameLast Name
JohnBrown32New York No. 1 Lake ParkNICEDEVELOPER
JimGreen42London No. 1 Lake ParkLOSER
JoeBlack32Sydney No. 1 Lake ParkCOOLTEACHER

Using JSX style API (introduced in 2.5.0)

Since this is just a syntax sugar for the prop columns, you can't compose Column and ColumnGroup with other Components.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddress
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park
Disabled User99Sydney No. 1 Lake Park

Rows can be selectable by making first column as a selectable column. You can use rowSelection.type to set selection type. Default is checkbox.

selection happens when clicking checkbox by default. You can see https://codesandbox.io/s/000vqw38rl if you need row-click selection behavior.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddress
Edward King 032London, Park Lane no. 0
Edward King 132London, Park Lane no. 1
Edward King 232London, Park Lane no. 2
Edward King 332London, Park Lane no. 3
Edward King 432London, Park Lane no. 4
Edward King 532London, Park Lane no. 5
Edward King 632London, Park Lane no. 6
Edward King 732London, Park Lane no. 7
Edward King 832London, Park Lane no. 8
Edward King 932London, Park Lane no. 9

To perform operations and clear selections after selecting some rows, use rowSelection.selectedRowKeys to control selected rows.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddress
Edward King 032London, Park Lane no. 0
Edward King 132London, Park Lane no. 1
Edward King 232London, Park Lane no. 2
Edward King 332London, Park Lane no. 3
Edward King 432London, Park Lane no. 4
Edward King 532London, Park Lane no. 5
Edward King 632London, Park Lane no. 6
Edward King 732London, Park Lane no. 7
Edward King 832London, Park Lane no. 8
Edward King 932London, Park Lane no. 9

Use rowSelection.selections custom selections, default no select dropdown, show default selections via setting to true.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Age
Address
Jim Green42London No. 1 Lake Park
John Brown32New York No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park
Jim Red32London No. 2 Lake Park

Use filters to generate filter menu in columns, onFilter to determine filtered result, and filterMultiple to indicate whether it's multiple or single selection, filterOnClose to specify whether to trigger filter when the filter menu closes.

Use defaultFilteredValue to make a column filtered by default.

Use sorter to make a column sortable. sorter can be a function of the type sorter: function(rowA, rowB) { ... } for sorting data locally.

sortDirections: ['ascend', 'descend'] defines available sort methods for each columns, effective for all columns when set on table props. You can set as ['ascend', 'descend', 'ascend'] to prevent sorter back to default status.

Use defaultSortOrder to make a column sorted by default.

If a sortOrder or defaultSortOrder is specified with the value ascend or descend, you can access this value from within the function passed to the sorter as explained above. Such a function can take the form: function(a, b, sortOrder) { ... }.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Age
Address
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park
Jim Red32London No. 2 Lake Park

You can use filterMode to change default filter interface, options: menu(default) and tree.

filterSearch is used for making filter dropdown items searchable.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Chinese Score
Math Score
English Score
John Brown986070
Jim Green986689
Joe Black989070
Jim Red889989

column.sorter support multiple to config the priority of sort columns. Though sorter.compare to customize compare function. You can also leave it empty to use the interactive only.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Age
Address
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park
Jim Red32London No. 2 Lake Park

Control filters and sorters by filteredValue and sortOrder.

  1. Defining filteredValue or sortOrder means that it is in the controlled mode.
  2. Make sure sortOrder is assigned for only one column.
  3. column.key is required.
CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Age
Address
John Brown32New York No. 1 Lake Park
Joe Black42London No. 1 Lake Park
Jim Green32Sydney No. 1 Lake Park
Jim Red32London No. 2 Lake Park

Implement a customized column search example via filterDropdown.

Add the boolean type parameter closeDropdown to the function clearFilters. Whether to close the filter menu is true by default. Add the boolean type parameter confirm to clear whether to submit the option during filtering. The default is true.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Gender
Email
No data
No data

This example shows how to fetch and present data from a remote server, and how to implement filtering and sorting in server side by sending related parameters to server.

Setting rowSelection.preserveSelectedRowKeys to keep the key when enable selection.

Note, this example use Mock API that you can look up in Network Console.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddress
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park
NameAgeAddress
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park

There are two compacted table sizes: middle and small. The small size is used in Modals only.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Header
NameCash AssetsAddress
John Brown¥300,000.00New York No. 1 Lake Park
Jim Green¥1,256,000.00London No. 1 Lake Park
Joe Black¥120,000.00Sydney No. 1 Lake Park

Add border, title and footer for table.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddressAction
John Brown32New York No. 1 Lake ParkDelete
Jim Green42London No. 1 Lake ParkDelete
Not Expandable29Jiangsu No. 1 Lake ParkDelete
Joe Black32Sydney No. 1 Lake ParkDelete

When there's too much information to show and the table can't display all at once.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAge
Address
John Brown32New York No. 1 Lake Park
Jim Green42London No. 1 Lake Park
Not Expandable29Jiangsu No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park

You can control the order of the expand and select columns by using Table.EXPAND_COLUMN and Table.SELECTION_COLUMN.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
RowHeadNameAgeHome phoneAddress
1John Brown320571-2209890918889898989New York No. 1 Lake Park
2Jim Green
3Joe Black320575-2209890918900010002Sydney No. 1 Lake Park
4Jim Red180575-2209890918900010002London No. 2 Lake Park
5Jake White1818900010002Dublin No. 2 Lake Park

Table column title supports colSpan that set in column.

Table cell supports colSpan and rowSpan that set in onCell return object. When each of them is set to 0, the cell will not be rendered.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
CheckStrictly:
NameAgeAddress
John Brown sr.60New York No. 1 Lake Park
Joe Black32Sydney No. 1 Lake Park

Display tree structure data in Table when there is field key children in dataSource, try to customize childrenColumnName property to avoid tree table structure.

You can control the indent width by setting indentSize.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddress
Edward King 032London, Park Lane no. 0
Edward King 132London, Park Lane no. 1
Edward King 232London, Park Lane no. 2
Edward King 332London, Park Lane no. 3
Edward King 432London, Park Lane no. 4
Edward King 532London, Park Lane no. 5
Edward King 632London, Park Lane no. 6
Edward King 732London, Park Lane no. 7
Edward King 832London, Park Lane no. 8
Edward King 932London, Park Lane no. 9
Edward King 1032London, Park Lane no. 10
Edward King 1132London, Park Lane no. 11
Edward King 1232London, Park Lane no. 12
Edward King 1332London, Park Lane no. 13
Edward King 1432London, Park Lane no. 14
Edward King 1532London, Park Lane no. 15
Edward King 1632London, Park Lane no. 16
Edward King 1732London, Park Lane no. 17
Edward King 1832London, Park Lane no. 18
Edward King 1932London, Park Lane no. 19
Edward King 2032London, Park Lane no. 20
Edward King 2132London, Park Lane no. 21
Edward King 2232London, Park Lane no. 22
Edward King 2332London, Park Lane no. 23
Edward King 2432London, Park Lane no. 24
Edward King 2532London, Park Lane no. 25
Edward King 2632London, Park Lane no. 26
Edward King 2732London, Park Lane no. 27
Edward King 2832London, Park Lane no. 28
Edward King 2932London, Park Lane no. 29
Edward King 3032London, Park Lane no. 30
Edward King 3132London, Park Lane no. 31
Edward King 3232London, Park Lane no. 32
Edward King 3332London, Park Lane no. 33
Edward King 3432London, Park Lane no. 34
Edward King 3532London, Park Lane no. 35
Edward King 3632London, Park Lane no. 36
Edward King 3732London, Park Lane no. 37
Edward King 3832London, Park Lane no. 38
Edward King 3932London, Park Lane no. 39
Edward King 4032London, Park Lane no. 40
Edward King 4132London, Park Lane no. 41
Edward King 4232London, Park Lane no. 42
Edward King 4332London, Park Lane no. 43
Edward King 4432London, Park Lane no. 44
Edward King 4532London, Park Lane no. 45
Edward King 4632London, Park Lane no. 46
Edward King 4732London, Park Lane no. 47
Edward King 4832London, Park Lane no. 48
Edward King 4932London, Park Lane no. 49
  • 1
  • 2

Display large amounts of data in scrollable view.

Specify width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no long word to break table layout.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Full Name
Age
Column 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8Column 9Column 10Column 11Column 12Column 13Column 14Column 15Column 16Column 17Column 18Column 19Column 20Action
Olivia32New York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York Parkaction
Ethan40London ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon Parkaction

To fix some columns and scroll inside other columns, and you must set scroll.x meanwhile.

Specify the width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no long word to break table layout.

A fixed value which is greater than table width for scroll.x is recommended. The sum of unfixed columns should not greater than scroll.x.

Note: v4 using sticky to implement fixed effect. IE 11 will downgrade to horizontal scroll.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Full NameAgeColumn 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8Column 9Column 10Column 11Column 12Column 13Column 14Column 15Column 16Column 17Column 18Column 19Column 20Action 1Action 2Action 3
Olivia32New York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York Parkactionactionaction
Ethan40London ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon Parkactionactionaction

Fixed column only when scroll some distance, and scroll to stack other columns. Recommend use with bordered.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5.14.0
Full NameAgeColumn 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8Column 9Column 10Column 11Column 12Column 13Column 14Column 15Column 16Column 17Column 18Column 19Column 20Action
Edward King 032London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0London, Park Lane no. 0action
Edward King 132London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1London, Park Lane no. 1action
Edward King 232London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2London, Park Lane no. 2action
Edward King 332London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3London, Park Lane no. 3action
Edward King 432London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4London, Park Lane no. 4action
Edward King 532London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5London, Park Lane no. 5action
Edward King 632London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6London, Park Lane no. 6action
Edward King 732London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7London, Park Lane no. 7action
Edward King 832London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8London, Park Lane no. 8action
Edward King 932London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9London, Park Lane no. 9action

A Solution for displaying large amounts of data with long columns.

Specify the width of columns if header and cell do not align properly. If specified width is not working or have gutter between columns, please try to leave one column at least without width to fit fluid layout, or make sure no long word to break table layout.

A fixed value which is greater than table width for scroll.x is recommended. The sum of unfixed columns should not greater than scroll.x.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Column 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8
New York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York ParkNew York Park
London ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon ParkLondon Park

Hide columns with hidden.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5.13.0
Name
OtherCompanyGender
Age
AddressCompany AddressCompany Name
StreetBlock
BuildingDoor No.
John Brown1Lake ParkC2035Lake Street 42SoftLake CoM
John Brown2Lake ParkC2035Lake Street 42SoftLake CoM
John Brown3Lake ParkC2035Lake Street 42SoftLake CoM
John Brown4Lake ParkC2035Lake Street 42SoftLake CoM
John Brown5Lake ParkC2035Lake Street 42SoftLake CoM
John Brown6Lake ParkC2035Lake Street 42SoftLake CoM
John Brown7Lake ParkC2035Lake Street 42SoftLake CoM
John Brown8Lake ParkC2035Lake Street 42SoftLake CoM
John Brown9Lake ParkC2035Lake Street 42SoftLake CoM
John Brown10Lake ParkC2035Lake Street 42SoftLake CoM

Group table head with columns[n].children.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
nameageaddressoperation
Edward King 0
32London, Park Lane no. 0Delete
Edward King 1
32London, Park Lane no. 1Delete

Table with editable cells. When work with shouldCellUpdate, please take care of closure.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
nameageaddressoperation
Edward 032London Park no. 0Edit
Edward 132London Park no. 1Edit
Edward 232London Park no. 2Edit
Edward 332London Park no. 3Edit
Edward 432London Park no. 4Edit
Edward 532London Park no. 5Edit
Edward 632London Park no. 6Edit
Edward 732London Park no. 7Edit
Edward 832London Park no. 8Edit
Edward 932London Park no. 9Edit

Table with editable rows.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NamePlatformVersionUpgradedCreatorDateAction
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
DateNameStatusUpgrade StatusAction
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
NamePlatformVersionUpgradedCreatorDateAction
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
DateNameStatusUpgrade StatusAction
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
NamePlatformVersionUpgradedCreatorDateAction
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
DateNameStatusUpgrade StatusAction
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
2014-12-24 23:12:00This is production nameFinishedUpgraded: 56
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish
ScreeniOS10.3.4.5654500Jack2014-12-24 23:12:00Publish

Showing more detailed info of every row.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddress
John Brown32Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text Long text
Jim Green42London No. 1 Lake Park
Joe Black32Sidney No. 1 Lake Park

By using components, we can integrate table with dnd-kit to implement drag sorting function.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameGenderAgeEmailAddress
John Brownmale32John Brown@example.comLondon No. 1 Lake Park
Jim Greenfemale42jimGreen@example.comLondon No. 1 Lake Park
Joe Blackfemale32JoeBlack@example.comSidney No. 1 Lake Park
George Hccmale20george@example.comSidney No. 1 Lake Park

By using components, we can integrate table with dnd-kit to implement column drag sorting function.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddress
John Brown32Long text Long
Jim Green42London No. 1 Lake Park
Joe Black32Sidney No. 1 Lake Park

Alternatively you can implement drag sorting with handler using dnd-kit.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddressLong Column Long Column Long ColumnLong Column Long ColumnLong Column
John Brown32New York No. 1 Lake Park, New York No. 1 Lake ParkNew York No. 1 Lake Park, New York No. 1 Lake ParkNew York No. 1 Lake Park, New York No. 1 Lake ParkNew York No. 1 Lake Park, New York No. 1 Lake Park
Jim Green42London No. 2 Lake Park, London No. 2 Lake ParkLondon No. 2 Lake Park, London No. 2 Lake ParkLondon No. 2 Lake Park, London No. 2 Lake ParkLondon No. 2 Lake Park, London No. 2 Lake Park
Joe Black32Sydney No. 1 Lake Park, Sydney No. 1 Lake ParkSydney No. 1 Lake Park, Sydney No. 1 Lake ParkSydney No. 1 Lake Park, Sydney No. 1 Lake ParkSydney No. 1 Lake Park, Sydney No. 1 Lake Park

Ellipsis cell content via setting column.ellipsis.

Cannot ellipsis table header with sorters and filters for now.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddressLong Column Long Column Long ColumnLong Column Long ColumnLong Column
John Brown32New York No. 1 Lake Park, New York No. 1 Lake ParkNew York No. 1 Lake Park, New York No. 1 Lake ParkNew York No. 1 Lake Park, New York No. 1 Lake ParkNew York No. 1 Lake Park, New York No. 1 Lake Park
Jim Green42London No. 2 Lake Park, London No. 2 Lake ParkLondon No. 2 Lake Park, London No. 2 Lake ParkLondon No. 2 Lake Park, London No. 2 Lake ParkLondon No. 2 Lake Park, London No. 2 Lake Park
Joe Black32Sydney No. 1 Lake Park, Sydney No. 1 Lake ParkSydney No. 1 Lake Park, Sydney No. 1 Lake ParkSydney No. 1 Lake Park, Sydney No. 1 Lake ParkSydney No. 1 Lake Park, Sydney No. 1 Lake Park

Ellipsis cell content via setting column.ellipsis.showTitle, use Tooltip instead of the html title attribute.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Age
Address
Edward King 032London, Park Lane no. 0
Edward King 133London, Park Lane no. 1
Edward King 234London, Park Lane no. 2
Edward King 335London, Park Lane no. 3
Edward King 436London, Park Lane no. 4

Custom empty status.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameBorrowRepayment
John Brown1033
Jim Green1000
Joe Black1010
Jim Red7545
Total19588
Balance107
NameDescription
LightEverything that has a beginning, has an end.
BambooEverything that has a beginning, has an end.
LittleEverything that has a beginning, has an end.
LightEverything that has a beginning, has an end.
BambooEverything that has a beginning, has an end.
LittleEverything that has a beginning, has an end.
LightEverything that has a beginning, has an end.
BambooEverything that has a beginning, has an end.
LittleEverything that has a beginning, has an end.
LightEverything that has a beginning, has an end.
BambooEverything that has a beginning, has an end.
LittleEverything that has a beginning, has an end.
LightEverything that has a beginning, has an end.
BambooEverything that has a beginning, has an end.
LittleEverything that has a beginning, has an end.
LightEverything that has a beginning, has an end.
BambooEverything that has a beginning, has an end.
LittleEverything that has a beginning, has an end.
LightEverything that has a beginning, has an end.
BambooEverything that has a beginning, has an end.
SummaryThis is a summary content

Set summary content by summary prop. Sync column fixed status with Table.Summary.Cell. You can fixed it by set Table.Summary fixed prop(since 4.16.0).

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
IDFistNameLastNameGroupAgeAddress 1Address 2Address 3Action
0
First_0
Last_0
25
London No. 0 Lake Park
Sydney No. 0 Lake Park
1
First_1
Last_1
26
New York No. 1 Lake Park
London No. 1 Lake Park
Sydney No. 1 Lake Park
2
First_2
Last_2
27
New York No. 2 Lake Park
London No. 2 Lake Park
Sydney No. 2 Lake Park
3
First_3
Last_3
28
New York No. 3 Lake Park
London No. 3 Lake Park
Sydney No. 3 Lake Park
4
First_4
Last_4
29
London No. 4 Lake Park
Sydney No. 4 Lake Park
5
First_5
Last_5
30
New York No. 5 Lake Park
London No. 5 Lake Park
Sydney No. 5 Lake Park
6
First_6
Last_6
31
New York No. 6 Lake Park
London No. 6 Lake Park
Sydney No. 6 Lake Park
7
First_7
Last_7
32
New York No. 7 Lake Park
London No. 7 Lake Park
Sydney No. 7 Lake Park
8
First_8
Last_8
33
London No. 8 Lake Park
Sydney No. 8 Lake Park
Group 0
Group 1
Group 2

Set virtual to enable virtual scroll, and scroll.x and scroll.y must be set at the same time with number type.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5.9.0
Name (all screens)
John Brown

Responsive columns.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
NameAgeAddressTagsAction
John Brown32New York No. 1 Lake ParkNICEDEVELOPER
Jim Green42London No. 1 Lake ParkLOSER
Joe Black32Sydney No. 1 Lake ParkCOOLTEACHER

Table pagination settings.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Full NameAgeColumn 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8Action
Edward 032London Park no. 0London Park no. 0London Park no. 0London Park no. 0London Park no. 0London Park no. 0London Park no. 0London Park no. 0action
Edward 132London Park no. 1London Park no. 1London Park no. 1London Park no. 1London Park no. 1London Park no. 1London Park no. 1London Park no. 1action
Edward 232London Park no. 2London Park no. 2London Park no. 2London Park no. 2London Park no. 2London Park no. 2London Park no. 2London Park no. 2action
Edward 332London Park no. 3London Park no. 3London Park no. 3London Park no. 3London Park no. 3London Park no. 3London Park no. 3London Park no. 3action
Edward 432London Park no. 4London Park no. 4London Park no. 4London Park no. 4London Park no. 4London Park no. 4London Park no. 4London Park no. 4action
Edward 532London Park no. 5London Park no. 5London Park no. 5London Park no. 5London Park no. 5London Park no. 5London Park no. 5London Park no. 5action
Edward 632London Park no. 6London Park no. 6London Park no. 6London Park no. 6London Park no. 6London Park no. 6London Park no. 6London Park no. 6action
Edward 732London Park no. 7London Park no. 7London Park no. 7London Park no. 7London Park no. 7London Park no. 7London Park no. 7London Park no. 7action
Edward 832London Park no. 8London Park no. 8London Park no. 8London Park no. 8London Park no. 8London Park no. 8London Park no. 8London Park no. 8action
Edward 932London Park no. 9London Park no. 9London Park no. 9London Park no. 9London Park no. 9London Park no. 9London Park no. 9London Park no. 9action
Scroll ContextFix Right

For long table,need to scroll to view the header and scroll bar,then you can now set the fixed header and scroll bar to follow the page.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Name
Age
Address
Action
John Brown2New York No. 0 Lake Park
John Brown12New York No. 1 Lake Park
John Brown22New York No. 2 Lake Park
John Brown32New York No. 3 Lake Park
John Brown42New York No. 4 Lake Park
John Brown52New York No. 5 Lake Park
John Brown62New York No. 6 Lake Park
John Brown72New York No. 7 Lake Park
John Brown82New York No. 8 Lake Park
John Brown92New York No. 9 Lake Park

Select different settings to see the result.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code

API

Common props ref:Common props

Table

PropertyDescriptionTypeDefaultVersion
borderedWhether to show all table bordersbooleanfalse
columnsColumns of tableColumnsType[]-
componentsOverride default table elementsTableComponents-
dataSourceData record array to be displayedobject[]-
expandableConfig expandable contentexpandable-
footerTable footer rendererfunction(currentPageData)-
getPopupContainerThe render container of dropdowns in table(triggerNode) => HTMLElement() => TableHtmlElement
loadingLoading status of tableboolean | Spin Propsfalse
localeThe i18n text including filter, sort, empty text, etcobjectDefault Value
paginationConfig of pagination. You can ref table pagination config or full pagination document, hide it by setting it to falseobject | false-
rowClassNameRow's classNamefunction(record, index): string-
rowKeyRow's unique key, could be a string or function that returns a stringstring | function(record): stringkey
rowSelectionRow selection configobject-
rowHoverableRow hoverbooleantrue5.16.0
scrollWhether the table can be scrollable, configobject-
showHeaderWhether to show table headerbooleantrue
showSorterTooltipThe header show next sorter direction tooltip. It will be set as the property of Tooltip if its type is objectboolean | Tooltip props & {target?: 'full-header' | 'sorter-icon' }{ target: 'full-header' }5.16.0
sizeSize of tablelarge | middle | smalllarge
sortDirectionsSupported sort way, could be ascend, descendArray[ascend, descend]
stickySet sticky header and scroll barboolean | {offsetHeader?: number, offsetScroll?: number, getContainer?: () => HTMLElement}-4.6.0 (getContainer: 4.7.0)
summarySummary content(currentData) => ReactNode-
tableLayoutThe table-layout attribute of table element- | auto | fixed-
fixed when header/columns are fixed, or using column.ellipsis
titleTable title rendererfunction(currentPageData)-
virtualSupport virtual listboolean-5.9.0
onChangeCallback executed when pagination, filters or sorter is changedfunction(pagination, filters, sorter, extra: { currentDataSource: [], action: paginate | sort | filter })-
onHeaderRowSet props on per header rowfunction(columns, index)-
onRowSet props on per rowfunction(record, index)-
onScrollTriggered when the table body is scrolled. Note that only vertical scrolling will trigger the event when virtualfunction(event)-5.16.0

Table ref

PropertyDescriptionTypeVersion
nativeElementThe wrap elementHTMLDivElement5.11.0
scrollToTrigger to scroll to target position. key match with record rowKey(config: { index?: number, key?: React.Key, top?: number }) => void5.11.0

onRow usage

Same as onRow onHeaderRow onCell onHeaderCell

<Table
onRow={(record, rowIndex) => {
return {
onClick: (event) => {}, // click row
onDoubleClick: (event) => {}, // double click row
onContextMenu: (event) => {}, // right button click row
onMouseEnter: (event) => {}, // mouse enter row
onMouseLeave: (event) => {}, // mouse leave row
};
}}
onHeaderRow={(columns, index) => {
return {
onClick: () => {}, // click header row
};
}}
/>

Column

One of the Table columns prop for describing the table's columns, Column has the same API.

PropertyDescriptionTypeDefaultVersion
alignThe specify which way that column is alignedleft | right | centerleft
classNameThe className of this columnstring-
colSpanSpan of this column's titlenumber-
dataIndexDisplay field of the data record, support nest path by string arraystring | string[]-
defaultFilteredValueDefault filtered valuesstring[]-
filterResetToDefaultFilteredValueclick the reset button, whether to restore the default filterbooleanfalse
defaultSortOrderDefault order of sorted valuesascend | descend-
ellipsisThe ellipsis cell content, not working with sorter and filters for now.
tableLayout would be fixed when ellipsis is true or { showTitle?: boolean }
boolean | {showTitle?: boolean }falseshowTitle: 4.3.0
filterDropdownCustomized filter overlayReactNode | (props: FilterDropdownProps) => ReactNode-
filteredWhether the dataSource is filteredbooleanfalse
filteredValueControlled filtered value, filter icon will highlightstring[]-
filterIconCustomized filter iconReactNode | (filtered: boolean) => ReactNode-
filterOnCloseWhether to trigger filter when the filter menu closesbooleantrue5.15.0
filterMultipleWhether multiple filters can be selectedbooleantrue
filterModeTo specify the filter interface'menu' | 'tree''menu'4.17.0
filterSearchWhether to be searchable for filter menuboolean | function(input, record):booleanfalseboolean:4.17.0 function:4.19.0
filtersFilter menu configobject[]-
filterDropdownPropsCustomized dropdown props, filterDropdownOpen and onFilterDropdownOpenChange were available before <5.22.0DropdownProps-5.22.0
fixed(IE not support) Set column to be fixed: true(same as left) 'left' 'right'boolean | stringfalse
keyUnique key of this column, you can ignore this prop if you've set a unique dataIndexstring-
renderRenderer of the table cell. value is the value of current cell; record is the value object of current row; index is the row number. The return value should be a ReactNodefunction(value, record, index) {}-
responsiveThe list of breakpoints at which to display this column. Always visible if not setBreakpoint[]-4.2.0
rowScopeSet scope attribute for all cells in this columnrow | rowgroup-5.1.0
shouldCellUpdateControl cell render logic(record, prevRecord) => boolean-4.3.0
showSorterTooltipIf header show next sorter direction tooltip, override showSorterTooltip in tableboolean | Tooltip props & {target?: 'full-header' | 'sorter-icon' }{ target: 'full-header' }5.16.0
sortDirectionsSupported sort way, override sortDirections in Table, could be ascend, descendArray[ascend, descend]
sorterSort function for local sort, see Array.sort's compareFunction. If it is server-side sorting, set to true, but if you want to support multi-column sorting, you can set it to { multiple: number }function | boolean | { compare: function, multiple: number }-
sortOrderOrder of sorted values: ascend descend nullascend | descend | null-
sortIconCustomized sort icon(props: { sortOrder }) => ReactNode-5.6.0
titleTitle of this columnReactNode | ({ sortOrder, sortColumn, filters }) => ReactNode-
widthWidth of this column (width not working?)string | number-
minWidthMin width of this column, only works when tableLayout="auto"number-5.21.0
hiddenHidden this columnbooleanfalse5.13.0
onCellSet props on per cellfunction(record, rowIndex)-
onFilterFunction that determines if the row is displayed when filteredfunction(value, record) => boolean-
onHeaderCellSet props on per header cellfunction(column)-

ColumnGroup

PropertyDescriptionTypeDefault
titleTitle of the column groupReactNode-

pagination

Properties for pagination.

PropertyDescriptionTypeDefault
positionSpecify the position of Pagination, could betopLeft | topCenter | topRight |bottomLeft | bottomCenter | bottomRightArray[bottomRight]

More about pagination, please check Pagination.

expandable

Properties for expandable.

PropertyDescriptionTypeDefaultVersion
childrenColumnNameThe column contains children to displaystringchildren
columnTitleSet the title of the expand columnReactNode-4.23.0
columnWidthSet the width of the expand columnstring | number-
defaultExpandAllRowsExpand all rows initiallybooleanfalse
defaultExpandedRowKeysInitial expanded row keysstring[]-
expandedRowClassNameExpanded row's classNamestring | (record, index, indent) => string-string: 5.22.0
expandedRowKeysCurrent expanded row keysstring[]-
expandedRowRenderExpanded container render for each rowfunction(record, index, indent, expanded): ReactNode-
expandIconCustomize row expand Icon. Ref examplefunction(props): ReactNode-
expandRowByClickWhether to expand row by clicking anywhere in the whole rowbooleanfalse
fixedWhether the expansion icon is fixed. Optional true left rightboolean | stringfalse4.16.0
indentSizeIndent size in pixels of tree datanumber15
rowExpandableEnable row can be expandable(record) => boolean-
showExpandColumnShow expand columnbooleantrue4.18.0
onExpandCallback executed when the row expand icon is clickedfunction(expanded, record)-
onExpandedRowsChangeCallback executed when the expanded rows changefunction(expandedRows)-

rowSelection

Properties for row selection.

PropertyDescriptionTypeDefaultVersion
checkStrictlyCheck table row precisely; parent row and children rows are not associatedbooleantrue4.4.0
columnTitleSet the title of the selection columnReactNode | (originalNode: ReactNode) => ReactNode-
columnWidthSet the width of the selection columnstring | number32px
fixedFixed selection column on the leftboolean-
getCheckboxPropsGet Checkbox or Radio propsfunction(record)-
hideSelectAllHide the selectAll checkbox and custom selectionbooleanfalse4.3.0
preserveSelectedRowKeysKeep selection key even when it removed from dataSourceboolean-4.4.0
renderCellRenderer of the table cell. Same as render in columnfunction(checked, record, index, originNode) {}-4.1.0
selectedRowKeysControlled selected row keysstring[] | number[][]
selectionsCustom selection config, only displays default selections when set to trueobject[] | boolean-
typecheckbox or radiocheckbox | radiocheckbox
onCellSet props on per cell. Same as onCell in columnfunction(record, rowIndex)-5.5.0
onChangeCallback executed when selected rows changefunction(selectedRowKeys, selectedRows, info: { type })-info.type: 4.21.0
onSelectCallback executed when select/deselect one rowfunction(record, selected, selectedRows, nativeEvent)-
onSelectAllCallback executed when select/deselect all rowsfunction(selected, selectedRows, changeRows)-
onSelectInvertCallback executed when row selection is invertedfunction(selectedRowKeys)-
onSelectNoneCallback executed when row selection is clearedfunction()-
onSelectMultipleCallback executed when row selection is changed by pressing shiftfunction(selected, selectedRows, changeRows)-

scroll

PropertyDescriptionTypeDefault
scrollToFirstRowOnChangeWhether to scroll to the top of the table when paging, sorting, filtering changesboolean-
xSet horizontal scrolling, can also be used to specify the width of the scroll area, could be number, percent value, true and 'max-content'string | number | true-
ySet vertical scrolling, can also be used to specify the height of the scroll area, could be string or numberstring | number-

selection

PropertyDescriptionTypeDefault
keyUnique key of this selectionstring-
textDisplay text of this selectionReactNode-
onSelectCallback executed when this selection is clickedfunction(changeableRowKeys)-

Using in TypeScript

import React from 'react';
import { Table } from 'antd';
import type { TableColumnsType } from 'antd';
interface User {
key: number;
name: string;
}
const columns: TableColumnsType<User> = [
{
key: 'name',
title: 'Name',
dataIndex: 'name',
},
];
const data: User[] = [
{
key: 0,
name: 'Jack',
},
];
const Demo: React.FC = () => (
<>
<Table<User> columns={columns} dataSource={data} />
{/* JSX style usage */}
<Table<User> dataSource={data}>
<Table.Column<User> key="name" title="Name" dataIndex="name" />
</Table>
</>
);
export default Demo;

Here is the CodeSandbox for TypeScript.

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
bodySortBgBackground color of table sorted columnstring#fafafa
borderColorBorder color of tablestring#f0f0f0
cellFontSizeFont size of table cell (large size by default)number14
cellFontSizeMDFont size of table cell (middle size)number14
cellFontSizeSMFont size of table cell (small size)number14
cellPaddingBlockVertical padding of table cellnumber16
cellPaddingBlockMDVertical padding of table cell (middle size)number12
cellPaddingBlockSMVertical padding of table cell (small size)number8
cellPaddingInlineHorizontal padding of table cell (large size by default)number16
cellPaddingInlineMDHorizontal padding of table cell (middle size)number8
cellPaddingInlineSMHorizontal padding of table cell (small size)number8
expandIconBgBackground of expand buttonstring#ffffff
filterDropdownBgColor of filter dropdownstring#ffffff
filterDropdownMenuBgBackground of filter dropdown menu itemstring#ffffff
fixedHeaderSortActiveBgBackground color of fixed table header when sortedstring#f0f0f0
footerBgBackground of footerstring#fafafa
footerColorColor of footer textstringrgba(0,0,0,0.88)
headerBgBackground of table headerstring#fafafa
headerBorderRadiusBorder radius of table headernumber8
headerColorColor of table header textstringrgba(0,0,0,0.88)
headerFilterHoverBgBackground color of table header filter button when hoveredstringrgba(0,0,0,0.06)
headerSortActiveBgBackground color of table header when sortedstring#f0f0f0
headerSortHoverBgBackground color of table header when sorted and hoveredstring#f0f0f0
headerSplitColorSplit border color of table headerstring#f0f0f0
rowExpandedBgBackground color of table expanded rowstringrgba(0,0,0,0.02)
rowHoverBgBackground color of table hovered rowstring#fafafa
rowSelectedBgBackground color of table selected rowstring#e6f4ff
rowSelectedHoverBgBackground color of table selected row when hoveredstring#bae0ff
selectionColumnWidthWidth of selection columnstring | number32
stickyScrollBarBgBackground of sticky scrollbarstringrgba(0,0,0,0.25)
stickyScrollBarBorderRadiusBorder radius of sticky scrollbarnumber100
Global TokenHow to use?

Note

According to the React documentation, every child in an array should be assigned a unique key. The values inside the Table's dataSource and columns should follow this rule. By default, dataSource[i].key will be treated as the key value for dataSource.

console warning

If dataSource[i].key is not provided, then you should specify the primary key of dataSource value via rowKey, as shown below. If not, warnings like the one above will show in browser console.

// primary key is uid
return <Table rowKey="uid" />;
// or
return <Table rowKey={(record) => record.uid} />;

FAQ

How to hide pagination when single page or no data?

You can set hideOnSinglePage with pagination prop.

Table will return to first page when filter data.

Table total page count usually reduce after filter data, we by default return to first page in case of current page is out of filtered results.

You may need to keep current page after filtering when fetch data from remote service, please check this demo as workaround.

Also you can use the action from extra param to determine when return to first page.

Why Table pagination show size changer?

In order to improve user experience, Pagination show size changer by default when total > 50 since 4.1.0. You can set showSizeChanger=false to disable this feature.

Why Table fully render when state change?

Table can not tell what state used in columns.render, so it always need fully render to avoid sync issue. You can use column.shouldCellUpdate to control render.

How to handle fixed column display over the mask layout?

Fixed column use z-index to make it over other columns. You will find sometime fixed columns also over your mask layout. You can set z-index on your mask layout to resolve.

How to custom render Table Checkbox(For example, adding Tooltip)?

Since 4.1.0, You can use rowSelection.renderCell to custom render Table Checkbox. If you want to add Tooltip, please refer to this demo.

Why does components.body.wrapper or components.body.row report an error when virtual is enabled?

Because virtual table needs to get its ref to do some calculations, so you need to use React.forwardRef wrapper and pass the ref to the dom