Skip to content

Table - API

Table Props

PropertyDescriptionTypeDefault
dataTable dataArray<Record<string, unknown>>[]
columnsColumn configurationTableColumn[][]
row-keyUnique row identifierstring | ((row) => string | number)'id'
sizeTable size'large' | 'default' | 'small''default'
widthTable widthnumber | string
heightTable heightnumber | string
max-heightTable max heightnumber | string
borderWhether to show borderboolean | 'full' | 'outer' | 'inner' | 'none'false
stripeWhether to show stripebooleanfalse
fitWhether to auto-fit parent container widthbooleantrue
show-headerWhether to show headerbooleantrue
show-indexWhether to show index columnbooleanfalse
highlight-current-rowWhether to highlight current rowbooleanfalse
current-row-keyCurrent selected row key (v-model)string | number
table-layoutTable layout'fixed' | 'auto''fixed'
empty-textText displayed when data is emptystring'No Data'
loadingWhether to show loading stateboolean | LoadingConfigfalse
resizableWhether columns are resizablebooleanfalse
lazyWhether to lazy load child nodesbooleanfalse
load-methodLazy load method(row) => Promise<unknown[]>
auto-heightAuto-fit content heightbooleanfalse
keep-scrollKeep scroll position after data updatebooleanfalse
scroll-optimizeEnable scroll optimizationbooleantrue
tooltip-effectOverflow tooltip theme'dark' | 'light''dark'
row-class-nameRow classNamestring | ((params) => string)
row-styleRow styleCSSProperties | ((params) => CSSProperties)
cell-class-nameCell classNamestring | ((params) => string)
cell-styleCell styleCSSProperties | ((params) => CSSProperties)
header-row-class-nameHeader row classNamestring | ((params) => string)
header-row-styleHeader row styleCSSProperties | ((params) => CSSProperties)
header-cell-class-nameHeader cell classNamestring | ((params) => string)
header-cell-styleHeader cell styleCSSProperties | ((params) => CSSProperties)
span-methodCell merge method(params) => { rowspan, colspan } | [rowspan, colspan]
selection-configSelection configurationSelectionConfig
sort-configSort configurationSortConfig
filter-configFilter configurationFilterConfig
tree-configTree configurationTreeConfig
expand-configExpand configurationExpandConfig
virtual-configVirtual scroll configurationVirtualConfig
paginationPagination configurationboolean | PaginationConfigfalse
summary-configSummary row configurationSummaryConfig
toolbar-configToolbar configurationToolbarConfig
drag-configDrag configurationDragConfig
row-configRow configurationRowConfig
header-configHeader configurationHeaderConfig
context-menu-configContext menu configurationContextMenuConfig
empty-configEmpty state configurationEmptyConfig
index-configIndex column configurationIndexConfig
sync-scrollWhether to sync scroll header and footerbooleantrue

Table Events

EventDescriptionType
row-clickTriggered when a row is clicked(row, column, event) => void
row-dblclickTriggered when a row is double-clicked(row, column, event) => void
row-contextmenuTriggered when a row is right-clicked(row, column, event) => void
cell-clickTriggered when a cell is clicked(row, column, cell, event) => void
cell-dblclickTriggered when a cell is double-clicked(row, column, cell, event) => void
header-clickTriggered when a header is clicked(column, event) => void
header-contextmenuTriggered when a header is right-clicked(column, event) => void
sort-changeTriggered when sort state changes(params: { column, prop, order }) => void
filter-changeTriggered when filter conditions change(filters: Record<string, unknown[]>) => void
page-changeTriggered when pagination changes(params: { currentPage, pageSize }) => void
selection-changeTriggered when selection state changes(rows, keys) => void
selectTriggered when a row is selected(selection, row) => void
select-allTriggered when select all / deselect all(selection) => void
current-changeTriggered when current row changes(currentRow, oldRow) => void
expand-changeTriggered when expand state changes(row, expandedRows) => void
scrollTriggered when table scrolls(params: { scrollTop, scrollLeft, isEnd }) => void
drag-endTriggered when drag ends(params: { type, oldIndex, newIndex, data }) => void
column-resizeTriggered when column width is resized(column, width) => void
column-visible-changeTriggered when column visibility changes(columns: TableColumn[]) => void
update:dataTriggered when data is updated(data: unknown[]) => void
update:currentRowKeyTriggered when current row key is updated(key: string | number) => void

Table Methods

MethodDescriptionParametersReturn
getSelectionRowsGet selected row dataunknown[]
getSelectionRowKeysGet selected row keys(string | number)[]
toggleRowSelectionToggle row selection state(row, selected?)
toggleAllSelectionToggle select all state
clearSelectionClear selection
setCurrentRowSet current row(row: unknown | null)
toggleRowExpansionToggle row expansion state(row, expanded?)
setExpandedRowKeysSet expanded rows(keys: (string | number)[])
getExpandedRowKeysGet expanded row keys(string | number)[]
sortManual sort(prop: string, order: 'asc' | 'desc' | null)
clearSortClear sort
filterManual filter(prop: string, values: unknown[])
clearFilterClear filter(prop?: string | string[])
doLayoutRecalculate layout
refreshRefresh table
scrollToScroll to specified position(options: { left?, top?, row?, rowIndex?, column?, columnIndex? })
getTableDataGet table data{ fullData, tableData }
exportDataExport data(config?: ExportConfig)Promise<string | void>
openImportOpen file picker for import(config?: ImportConfig)Promise<unknown[]>
importFileImport from File object(file: File, config?: ImportConfig)Promise<unknown[]>
importDataImport from text/array(content: string | unknown[], config?: ImportConfig)Promise<unknown[]>
printPrint table(config?: PrintConfig)Promise<void>
printMultiplePrint multiple tables(tables: Array<{ title?, data, columns?, config? }>, config?)Promise<void>
printTemplatePrint custom template(templateHtml: string, config?: PrintConfig)Promise<void>
toggleFullscreenToggle fullscreen
getColumnsGet column configurationTableColumn[]
setColumnVisibleSet column visibility(prop: string, visible: boolean)
resetColumnsReset column configuration
insertRowInsert row(row, index?)
removeRowRemove row(row | rows)
updateRowUpdate row(row, newRow)

Table Slots

SlotDescriptionParameters
toolbarToolbar content
toolbar-leftToolbar left content
toolbar-rightToolbar right content
emptyContent displayed when data is empty
loadingContent displayed when loading
expandExpand row content{ row, rowIndex }
summarySummary row content
[prop]Custom column content{ row, column, rowIndex, cellValue }
header-[prop]Custom header content{ column, columnIndex }
summary-[prop]Custom summary column content{ column, columnIndex, data }

TableColumn Configuration

PropertyDescriptionTypeDefault
keyColumn unique identifierstring
propColumn field namestring
labelColumn titlestring
widthColumn widthnumber | string
minWidthMinimum column widthnumber | string80
maxWidthMaximum column widthnumber | string
alignContent alignment'left' | 'center' | 'right''left'
headerAlignHeader alignment'left' | 'center' | 'right''left'
fixedColumn fixed position'left' | 'right' | true
sortableWhether sortableboolean | 'custom'false
filterableWhether filterablebooleanfalse
filtersFilter optionsArray<{ text, value }>
filterMultipleWhether multi-select filterbooleantrue
filterMethodFilter method(value, row, column) => boolean
resizableWhether resizablebooleantrue
draggableWhether draggableboolean
showOverflowTooltipWhether to show overflow tooltipboolean | { effect?, placement?, offset? }false
ellipsisEllipsis configurationboolean | { tooltip?: boolean, lineClamp?: number }
classNameColumn class namestring
headerClassNameHeader class namestring
styleColumn styleCSSProperties
headerStyleHeader styleCSSProperties
visibleWhether visiblebooleantrue
typeColumn type'selection' | 'index' | 'expand' | 'radio'
formatterFormatter function(row, column, cellValue, rowIndex) => string
displayMapValue to display text mappingRecord<string, string>
renderCustom render function(params) => VNode
headerRenderCustom header render function(params) => VNode
headerPrefixIconHeader prefix iconstring | Component
headerSuffixIconHeader suffix iconstring | Component
childrenSub-columns (multi-level header)TableColumn[]
treeNodeWhether tree expand columnbooleanfalse
colSpanColumn span countnumber
sortMethodCustom sort method(a, b, order) => number
sortByCustom sort fieldstring | ((row) => unknown)
defaultSortDefault sort'asc' | 'desc' | null

SelectionConfig

PropertyDescriptionTypeDefault
typeSelection type'checkbox' | 'radio''checkbox'
selectedRowKeysSelected row keys(string | number)[]
reserveWhether to preserve cross-page selectionsbooleantrue
checkableFunction to determine if row is selectable(row, rowIndex) => boolean
selectAllModeSelect all mode'all' | 'currentPage''currentPage'
columnWidthSelection column widthnumber | string50
showSelectAllWhether to show select allbooleantrue
onChangeSelection change callback(keys, rows) => void

VirtualConfig

PropertyDescriptionTypeDefault
enabledWhether to enable virtual scrollbooleanfalse
rowHeightRow heightnumber | ((row, index) => number)48
bufferBuffer row countnumber5
overscanPre-render row countnumber3
columnVirtualWhether to enable column virtual scrollbooleanfalse
columnBufferColumn buffer countnumber3

TreeConfig

PropertyDescriptionTypeDefault
childrenKeyChildren field namestring'children'
indentIndent pixelsnumber16
accordionWhether accordion modebooleanfalse
expandAllWhether to expand all by defaultbooleanfalse
defaultExpandLevelDefault expand levelnumber
defaultExpandedKeysDefault expanded nodes(string | number)[]
lazyWhether lazy loadbooleanfalse
loadMethodLazy load method(row) => Promise<unknown[]>
triggerExpand trigger method'default' | 'row' | 'cell''default'
expandIconExpand iconstring | Component
collapseIconCollapse iconstring | Component
leafIconLeaf node iconstring | Component
showLineWhether to show connecting linesbooleanfalse
lineStyleConnecting line style'solid' | 'dashed' | 'dotted''solid'

ExpandConfig

PropertyDescriptionTypeDefault
defaultExpandedRowKeysDefault expanded row keys(string | number)[]
expandAllWhether to expand all rowsbooleanfalse
accordionWhether accordion modebooleanfalse
iconPositionExpand icon position'left' | 'right''left'
columnWidthExpand column widthnumber | string50
expandableFunction to determine if row is expandable(row, rowIndex) => boolean
renderCustom render function(params: { row, rowIndex }) => VNode
lazyWhether lazy loadbooleanfalse
loadMethodLazy load method(row) => Promise<VNode>
showIconWhether to show expand iconbooleantrue
onChangeExpanded rows change callback(expandedRowKeys) => void

SortConfig

PropertyDescriptionTypeDefault
defaultSortDefault sort column{ prop: string, order: 'asc' | 'desc' | null }
multipleWhether multi-column sortbooleanfalse
triggerSort trigger method'cell' | 'header''header'
remoteWhether remote sortbooleanfalse
iconPositionSort icon position'left' | 'right''right'
sortMethodsCustom sort methods collectionRecord<string, (a, b, order) => number>

SummaryConfig

PropertyDescriptionTypeDefault
positionSummary row position'top' | 'bottom''bottom'
fixedWhether to fix summary rowbooleanfalse
textSummary textstring'Total'
classNameSummary row class namestring
styleSummary row styleCSSProperties
methodSummary calculation method(params: { columns, data }) => Array<string | number | VNode>

DragConfig

PropertyDescriptionTypeDefault
rowWhether rows are draggablebooleanfalse
columnWhether columns are draggablebooleanfalse
handleDrag handle selectorstring
animationAnimation duration (ms)number150
onDragStartDrag start callback(params) => void
onDragEndDrag end callback(params) => void
crossTableWhether cross-table dragbooleanfalse
dragClassDrag style classstring
ghostClassGhost element style classstring

FilterConfig

PropertyDescriptionTypeDefault
remoteWhether remote filterbooleanfalse
iconFilter iconstring | Component
maxHeightFilter panel max heightnumber | string
widthFilter panel widthnumber | string

PaginationConfig

PropertyDescriptionTypeDefault
currentPageCurrent page numbernumber1
pageSizeItems per pagenumber10
totalTotal itemsnumber
pageSizesItems per page optionsnumber[][10, 20, 50, 100]
layoutPagination layoutstring'total, sizes, prev, pager, next, jumper'
positionPagination position'top' | 'bottom' | 'both''bottom'
remoteWhether server-side paginationbooleanfalse
alignAlignment'left' | 'center' | 'right''left'
smallWhether small paginationbooleanfalse
backgroundWhether to show backgroundbooleanfalse
hideOnSinglePageHide when single pagebooleanfalse

LoadingConfig

PropertyDescriptionTypeDefault
visibleWhether loadingbooleanfalse
textLoading textstring
iconLoading iconstring | Component
backgroundLoading background colorstring
renderCustom render() => VNode

EmptyConfig

PropertyDescriptionTypeDefault
imageEmpty state imagestring
descriptionEmpty state descriptionstring'No Data'
renderCustom render() => VNode

IndexConfig

PropertyDescriptionTypeDefault
labelIndex column titlestring'#'
widthIndex column widthnumber | string60
fixedIndex column fixed position'left' | 'right' | true
methodCustom index method(rowIndex) => number | string

ToolbarConfig

PropertyDescriptionTypeDefault
visibleWhether to show toolbarbooleantrue
refreshWhether to show refresh buttonbooleanfalse
columnSettingWhether to show column settingsbooleanfalse
densityWhether to show density settingsbooleanfalse
fullscreenWhether to show fullscreen buttonbooleanfalse
exportWhether to show export buttonboolean | ExportConfigfalse
printWhether to show print buttonbooleanfalse
searchWhether to show search boxboolean | { placeholder?, width? }false
customCustom buttonsArray<{ icon?, text?, onClick?, disabled? }>

RowConfig

PropertyDescriptionTypeDefault
heightRow heightnumber | string
classNameRow class namestring | ((params) => string)
styleRow styleCSSProperties | ((params) => CSSProperties)
highlightCurrentWhether to highlight current rowbooleanfalse
stripeWhether to show stripebooleanfalse
hoverWhether to highlight on hoverbooleantrue

HeaderConfig

PropertyDescriptionTypeDefault
heightHeader heightnumber | string
classNameHeader class namestring
styleHeader styleCSSProperties
visibleWhether to show headerbooleantrue
backgroundHeader background colorstring

ContextMenuConfig

PropertyDescriptionTypeDefault
enabledWhether to enable context menubooleanfalse
itemsMenu item configurationArray<{ key, label, icon?, disabled?, onClick?, divider?, children? }>
renderCustom render(params: { row, column, rowIndex }) => VNode

Theme Variables

VariableDescriptionDefault
--yh-table-border-colorBorder colorvar(--yh-border-color-lighter)
--yh-table-header-bgHeader backgroundvar(--yh-fill-color-light)
--yh-table-header-text-colorHeader text colorvar(--yh-text-color-primary)
--yh-table-header-font-weightHeader font weightvar(--yh-font-weight-semibold)
--yh-table-row-bgRow backgroundvar(--yh-bg-color)
--yh-table-row-hover-bgRow hover backgroundvar(--yh-fill-color-light)
--yh-table-row-stripe-bgStripe backgroundvar(--yh-fill-color-lighter)
--yh-table-row-current-bgCurrent row backgroundvar(--yh-color-primary-light-9)
--yh-table-row-selected-bgSelected row backgroundvar(--yh-color-primary-light-8)
--yh-table-row-success-bgSuccess row backgroundvar(--yh-color-success-light-9)
--yh-table-row-warning-bgWarning row backgroundvar(--yh-color-warning-light-9)
--yh-table-text-colorText colorvar(--yh-text-color-regular)
--yh-table-empty-text-colorEmpty state text colorvar(--yh-text-color-secondary)
--yh-table-font-sizeFont sizevar(--yh-font-size-base)
--yh-table-cell-paddingCell padding12px 0
--yh-table-cell-spacingCell content spacing12px
--yh-table-fixed-left-shadowLeft fixed column shadowinset 10px 0 8px -8px rgba(0,0,0,0.15)
--yh-table-fixed-right-shadowRight fixed column shadowinset -10px 0 8px -8px rgba(0,0,0,0.15)

Released under the MIT License.