Skip to content

API Reference ​

This page is the behavioral reference: props, events, slots, defaults and controlled/uncontrolled rules.

For the full relationships of TypeScript types such as TableColumnsType, Breakpoint and RowSelection, see the type reference (Chinese). This page only mentions type names without re-expanding their definitions.

Import entry ​

Import components, constants and types from @vtable-guild/vtable-guild:

ts
import {
  VTable,
  VTableSummary,
  EXPAND_COLUMN,
  SELECTION_COLUMN,
  type TableColumnsType,
  type RowSelection,
  type Expandable,
} from '@vtable-guild/vtable-guild'

VTable Props ​

Data and structure ​

PropTypeDefaultDescription
dataSourceTRecord[][]Table data source.
columnsTableColumnsType<TRecord>[]Column configuration: leaf columns, column groups and sentinel constants.
columnOrderKey[]-Column display order. See column display (Chinese).
rowKeystring | (record) => Key-Unique row identity; passing it explicitly is recommended.
childrenColumnNamestring'children'Child field name for tree data.
indentSizenumber15Tree data indent width in px.

Visuals and layout ​

PropTypeDefaultDescription
size'small' | 'middle' | 'large''large'Table size, aligned with ant-design-vue naming.
loadingboolean | objectfalseLoading state; the object form accepts spinning, indicator, tip.
borderedbooleanfalseShow borders.
stripedbooleanfalseZebra striping.
hoverablebooleantrueRow hover highlight.
tableLayout'auto' | 'fixed'-Table layout mode.
showHeaderbooleantrueWhether to show the header.
headerEllipsisbooleanfalseAlso ellipsize headers of columns with column.ellipsis.
classstring-Extra class on the root node.

Scrolling and positioning ​

PropTypeDefaultDescription
scroll{ x?: number | string; y?: number | string }-Horizontal and vertical scroll config; providing y creates a fixed-header scroll area. A numeric y sets a fixed viewport; y: 'auto' fills a parent with a definite height and deducts the header and external summary. In virtual mode, other strings must be positive pixel values; relative units fall back to 400px with a development warning.
stickyboolean | TableStickyfalseSticky header, summary or horizontal scrollbar config.
virtualbooleanfalseEnable virtual scrolling; requires scroll.y.
virtualColumnbooleanfalseHorizontal virtualization: render only columns in the viewport; requires virtual. Pays off with many columns, see virtualization (Chinese).
rowHeightnumber-Fixed row height (px), only in virtual mode. Declaring it skips all row measurement and makes viewport math O(1) — only pass it if every row truly has that height.
getPopupContainer(triggerNode) => HTMLElement-Mount container for filter and selection menus.

Theming and locale ​

PropTypeDefaultDescription
uiSlotProps-Theme slot class overrides for this table instance. See the ui slot reference (Chinese).
localeLocaleNameglobal config or 'zh-CN'Locale identifier for this table instance.
localesLocaleRegistry{}Extra locale packs registered on this instance.
localeOverridesDeepPartial<VTableGuildTableLocale>{}Partial locale overrides for this instance.

Interactive capabilities ​

PropTypeDefaultDescription
rowSelectionRowSelection<TRecord>-Enable the selection column.
expandableExpandable<TRecord>-Enable expandable rows.
rowDraggablebooleanfalseEnable row drag sorting, see row drag sort (Chinese).
expandedRowKeysKey[]-Controlled expanded keys for tree data.
defaultExpandedRowKeysKey[]-Default expanded keys for tree data.
defaultExpandAllRowsbooleanfalseExpand all tree nodes by default.
onExpand(expanded, record) => void-Tree expand/collapse callback.
onExpandedRowsChange(expandedKeys) => void-Tree expanded-keys callback.
transformCellText(opt) => unknown-Transform cell text; opt contains text, column, record and index.
showSorterTooltipbooleantrueTable-level sorter tooltip switch, overridable per column.
sortDirectionsSortOrder[]-Table-level sort direction list, used as the default for columns.

Custom structure ​

PropTypeDefaultDescription
rowClassNamestring | RowClassName<TRecord>-Extra class for body rows.
customRowGetComponentProps<TRecord>-Inject attributes, events and styles on body rows.
customHeaderRow(columns, index?) => CellAdditionalProps-Inject attributes, events and styles on header rows.
title(data) => VNodeChild-Table title render function.
footer(data) => VNodeChild-Table footer render function.

Column behavior ​

Basics ​

FieldTypeDefaultDescription
keyKey-Unique column identity; passing it explicitly is recommended.
titleVNodeChild | function-Column title: text, VNode or render function.
dataIndexDataIndex-Data field path, e.g. 'name' or ['address', 'city'].
widthnumber | string-Column width; numbers are treated as px.
alignAlignType-Cell content alignment.
ellipsisboolean | { showTitle?: boolean }falseEllipsize overflowing cell content; showTitle: false disables the hover tooltip.
classNamestring-Extra class for the column's cells.
colSpannumber-Header cell colSpan.
visiblebooleantrueWhether the column is shown, see column display (Chinese).
responsiveBreakpoint[]-Show the column when any listed breakpoint matches the screen.

Custom rendering ​

FieldTypeDefaultDescription
customRender(ctx) => VNodeChild | RenderedCell-Custom body cell content. Returning RenderedCell also sets cell props.
customCell(record, index, column?) => CellAdditionalProps-Inject attributes, events and styles on body cells.
customHeaderCell(column, index) => CellAdditionalProps-Inject attributes, events and styles on header cells.
ts
customRender: ({ text, index }) =>
  index === 0
    ? { children: String(text), props: { colSpan: 2, style: { fontWeight: 'bold' } } }
    : String(text)

Fixed columns and resizing ​

FieldTypeDefaultDescription
fixed'left' | 'right' | true-Fixed side; true equals 'left'.
resizablebooleanfalseWhether the column width is drag-adjustable.
minWidthnumber50Minimum width while resizing.
maxWidthnumber-Maximum width while resizing.

Sorting ​

FieldTypeDefaultDescription
sorterColumnSorter<TRecord>-Enable sorting: default compare, custom compare fn or multi-column object.
sortOrderSortOrder-Controlled sort order.
defaultSortOrderSortOrder-Uncontrolled default order, effective on first render only.
sortDirectionsSortOrder[]['ascend', 'descend']Sort directions available for this column.
showSorterTooltipbooleaninherits table configColumn-level sorter tooltip switch.

Table-level sortDirections and showSorterTooltip act as defaults; column-level config wins.

Filtering ​

FieldTypeDefaultDescription
filtersColumnFilterItem[]-Filter menu items; renders the filter icon in the header.
onFilter(value, record) => boolean-Filter function; return true to keep the row.
filterMultiplebooleantrueWhether multiple filter values can be picked.
filteredValueArray<string | number | boolean> | null-Controlled filter values.
defaultFilteredValueArray<string | number | boolean>-Uncontrolled default filter values.
customFilterDropdownbooleanfalseUse the table-level customFilterDropdown slot.
filterSearchboolean | (input, filter) => booleanfalseSearch within filter items.
filterMode'menu' | 'tree''menu'Filter item presentation mode.
filterResetToDefaultFilteredValuebooleanfalseReset restores the default filter values.
filterDropdownOpenboolean-Controlled filter dropdown visibility.
onFilterDropdownOpenChange(visible) => void-Filter dropdown visibility callback.
filteredboolean-Externally control the filter icon highlight; does not filter.
filterIcon({ filtered }) => VNodeChild-Custom filter icon.
filterDropdownVNodeChild | (props) => VNodeChild-Column-level custom filter panel; overrides the table slot.

Column groups ​

FieldTypeDefaultDescription
childrenArray<ColumnType<TRecord> | ColumnGroupType<TRecord>>-Child columns. With children present the column is a group.

Column groups do not receive leaf-column behaviors such as sorting, filtering, dataIndex and customRender.

Row Selection ​

rowSelection enables the selection column: multiple, single, tree-linked, batch menus and controlled state.

FieldTypeDefaultDescription
type'checkbox' | 'radio''checkbox'Selection type.
selectedRowKeysKey[]-Controlled selected keys.
defaultSelectedRowKeysKey[]-Default selected keys.
onChange(keys, rows) => void-Selection change callback.
onSelect(record, selected, rows) => void-Single-row selection callback.
onSelectMultiple(selected, rows, changeRows) => void-Shift multi-select callback.
onSelectAll(selected, rows, changeRows) => void-Select-all callback.
onSelectInvert(keys) => void-Invert-selection callback.
onSelectNone() => void-Clear-selection callback.
getCheckboxProps(record) => { disabled?, name? }-Inject attributes on selection controls.
columnWidthnumber | string-Selection column width.
fixedboolean | 'left' | 'right'-Fixed position of the selection column.
columnTitlestring | VNodeChild-Selection column header content.
renderCell(value, record, index, originNode) => VNodeChild | RenderedCell-Custom selection cell.
checkStrictlybooleantrueParent/child independent selection in tree data.
selectionsboolean | arrayfalseDefault or custom batch-selection menu.
hideSelectAllbooleanfalseHide the select-all checkbox and dropdown.
preserveSelectedRowKeysbooleanfalseKeep selected keys when the data source changes.

Default batch-selection constants: see SelectionSentinel (Chinese).

Expandable ​

expandable configures expandable row content. Tree-data expand props live at the VTable top level.

FieldTypeDefaultDescription
expandedRowRender(record, index, indent, expanded) => VNodeChild-Expanded row content render function.
expandedRowKeysKey[]-Controlled expanded row keys.
defaultExpandedRowKeysKey[]-Default expanded row keys.
expandRowByClickbooleanfalseExpand on full-row click.
expandIcon(props) => VNodeChild-Custom expand icon.
onExpand(expanded, record) => void-Expand/collapse callback.
onExpandedRowsChange(expandedKeys) => void-Expanded-keys callback.
columnWidthnumber | string-Expand column width.
fixed'left' | 'right' | true-Fixed position of the expand column; true = 'left'.
defaultExpandAllRowsbooleanfalseExpand all rows by default.
rowExpandable(record) => boolean-Whether a row is expandable.
showExpandColumnbooleantrueWhether to show the expand column.
expandedRowClassNamestring | RowClassName<TRecord>-Class for expanded rows.

Events ​

EventPayloadDescription
change(filters, sorter, extra)Unified event after sorting, filtering and selection.
resizeColumn(column, width)Fired after a column resize drag ends.
rowDragEnd(newData, info)Fired when row drag sorting finishes with a changed order, see row drag sort (Chinese).

change currently has no pagination payload. extra.action is 'sort', 'filter' or 'select'.

ts
function handleChange(filters, sorter, extra) {
  if (extra.action === 'sort') {
    // sync sort state or request remote data
  }
}

Slots ​

SlotPayload typeDescription
bodyCellTableBodyCellSlotProps<TRecord>Custom cell content.
headerCellTableHeaderCellSlotProps<TRecord>Custom header cell content.
empty()Custom empty state.
loading()Custom loading state.
customFilterDropdownCustomFilterDropdownSlotProps<TRecord>Table-level custom filter panel.
customFilterIcon{ column, filtered }Table-level custom filter icon.
titleTableDataSlotProps<TRecord>Custom title area.
footerTableDataSlotProps<TRecord>Custom footer area.
summary()Custom summary area.

These are Vue slots. To restyle structure via classes, see the ui slot reference (Chinese).

VTableSummary ​

VTableSummary renders summary rows.

ComponentCommon propsDescription
VTableSummaryfixedSummary container; fixed accepts true, 'top', 'bottom'.
VTableSummary.Row-Summary row.
VTableSummary.Cellindex, colSpan, rowSpan, alignSummary cell.