Skip to main content

Table

Enter parameters to quickly create table data. The default settings include pagination.

import AcroolTable from '@acrool/react-table';

const data: IPaginateData[] = [
{id: 1, name: 'Jack Wu', role: 'Admin', amount: 230},
{id: 2, name: 'Imagine Chiu', role: 'Guest', amount: 120},
{id: 3, name: 'Jason Dinwiddie', role: 'Manage', amount: 200},
{id: 4, name: 'Gloria Lu', role: 'Guest', amount: 300},
];

<AcroolTable
title={{
name: {text: 'Name', col: 'auto'},
role: {text: 'Role', col: '120px'},
}}
data={data.map(row => {
return {
id: row.id,
field: {
name: row.name,
role: row.role,
},
};
})}
/>
Title
Text
Image Chiuthis is a frontend coder
Gary Chienthis is a backend coder
Loading...
Show 1 - 0 itemTotal 0 item / 1 Page

Props

Props NameTypeRequiredDefaultDescription
styleCSS.Properties
classNamestring
isDarkbooleanDark theme
isFetchingbooleanWhether to display the read mask
titleTTableTitle<K>Header list settings
dataITableBody<K,I>[]Data list settings
footerTFooter<K>Footer list settings
headerLineHeightTLineHeightHeader row height setting
bodyLineHeightTLineHeightBody row height setting
footerLineHeightTLineHeightFooter row height setting
cellLineHeightTLineHeightcell mode row height setting
gapstring5pxField item spacing settings
paginateInfoIPaginateInfo{totalItems: 0,totalPages: 1}Currently specified page parameter
paginateMetaIPaginateMetaPage count information
nextTextReactNodeNext page button text
prevTextReactNodePrevious page button text
isVisibleHeaderbooleantrueWhether to display header
isVisiblePaginatebooleantrueWhether to display pagination
isEnableChangePageScrollTopbooleantrueWhether to move to the top when switching pages
tableCellMediaSizenumberMaximum size of Cell display mode
onChangePageTOnChangePageMethod when changing page
pageLimitOptionsnumber[][8, 40, 72, 150]Select the menu to display the number of items per page
orderByTypeIOrderByTypeAlignment categories
renderNoData() => JSX.Element|stringContent when no data is available
renderPageButton(args: IPageButtonArgs) => ReactNodeRender page feed button
renderFetching() => JSX.Element|string'Loading...'Render and read block content
type TLineHeight = `${number}${TSizeUnit}`|'auto'

TTableTitle

type TTableTitle<K extends string> = {
[P in K]: ITitleField;
}

ITitleField

Props NameTypeRequiredDescription
classNamestring
colTTitleColwidth
textstring|number | ReactNodeDisplay content
titleAlign'left'|'center' |'right'Horizontal Alignment
isEnableSortbooldanWhether to enable sorting function
isStickybooldanWhether to enable the sticky function
isHiddenbooldanWhether to hide the field
type TSizeUnit = 'px' | '%' | 'em' | 'fr' | 'rem';
type TTitleCol = true|'auto'|number|`${number}${TSizeUnit}`|'min-content'|'max-content'|`minmax('${number}${TSizeUnit}', '${number}${TSizeUnit}')`;

IConfig

Props NameTypeRequiredDescription
colSpannumber
dataAlign'left'|'center' |'right'Vertical alignment
dataVertical'top'|'center' |'bottom'Horizontal alignment

IOrderByType

Props NameTypeRequiredDefaultDescription
ascstringCorresponding strings arranged in ascending order
descstringArrange corresponding strings in descending exponentiation

ITableBody

Props NameTypeRequiredDefaultDescription
idIIdentification ID (Array key)
classNamestring
detailJSX.Element | TBodyDataDetail<K>[]Additional details
disabledbooleanDisable clicks
onClickRow(collapse: () => void) => voidWhen clicking on the data column
fieldTBodyDataField<K>Field settings
type TBodyDataDetail<K extends TBodyDataFieldKey> = {
[P in K]?: { value: TFieldValue } & IConfig;
}
type TFieldFunc = (args: TFieldFuncArgs) => TFieldValue;

type TBodyDataFieldKey = string;
type TFieldValue = string | number | boolean | JSX.Element;

type TBodyDataField<K extends TBodyDataFieldKey> = {
[P in K]?: TFieldValue | TFieldFunc | { value: TFieldValue } & IConfig;
}

IOrder

Props NameTypeRequiredDefaultDescription
orderFieldnumber
orderBynumber