Skip to content

API Reference ​

This page provides component behavior reference and a composable index: look up props, events, slots, defaults, controlled-mode rules, and function options, state and methods.

For the full relationships of TypeScript types such as TableColumnsType, Breakpoint and RowSelection, see the Type reference. The complete Type Declarations at the end of this page let you look up parameters and return values directly.

Import entry ​

We recommend importing components, constants and types from the single @vtable-guild/vtable-guild entry.

ts
import {
  VTable,
  VTableToolbar,
  VTableColumnSettings,
  VTableSummary,
  useTableRequest,
  useTableQuery,
  useTableEdit,
  createTableRenderers,
  EXPAND_COLUMN,
  SELECTION_COLUMN,
  type TableColumnsType,
  type RowSelection,
  type Expandable,
  type TableInstance,
} from '@vtable-guild/vtable-guild'

Composable index ​

Find a function by name below and open its complete API. Feature pages keep the usage examples, while their API sections collect options and return values. Import all these functions from @vtable-guild/vtable-guild.

FunctionPurposeComplete API
useTableQueryQuery drafts, param transforms, submission and reset.Query submission
useTableEditRow drafts, validation, saving, cancellation and controlled details.Editing
useTableEditableConnect column editors to row drafts and host controls.Column editors
useTableRequestRemote requests, pagination, loading and refresh.Request management
useTableDictionaryOptions, search and loading for a shared dictionary.Remote dictionaries
useColumnStateRestore and save column visibility, pinning and order preferences.Column state
useColumnsParse leaf columns and grouped header metadata.Low-level column parsing
useRowDragSortCompose native row drag events and controlled reorder results.Low-level row dragging
useThemeCompose theme and instance slot classes for custom components.Low-level theming

Toolbar and column settings ​

VTableToolbar is a standalone component; place it in VTable's #title slot to compose the two. It shares v-model:columns and v-model:size with the table. Reload, density and column settings are enabled by default; full screen is enabled with options.fullScreen and targets the surrounding table by default, and fullscreenTarget can point at another element. Reload only emits reload; the application manages data requests and loading.

#actions adds application buttons such as export or create; #settings replaces the built-in tools entirely; options: false turns off only the built-in tools and keeps the application slots. See Toolbar for the complete props, events, slots and a runnable export example.

Use VTableColumnSettings on its own when you only need density and column settings. It covers visibility, pinning to the left or right, and drag reordering of top-level columns within the same fixed region. options.density / setting / fixed / draggable toggle each entry; the column field disable locks actions, hideInSetting hides the item, and #columnLabel customizes labels. The panel's reset restores initial visibility only; useColumnState().reset() restores visibility, pinning and order. See Column display and order.

Query and editing protocols ​

These Vue composables follow the query state of Ant Design ProTable and the row state of EditableProTable. They do not generate a complete form from columns. Controls, form validation and data submission stay with the host UI library and application services, and antdv / element-plus share the same protocol.

EntryPurposeFull API
useTableQuery<TValues, TParams>Query draft, parameter transforms, submit and reset. Input only changes the draft; submit() transforms it and then submits.Query submission
useTableEdit<TRecord>Row editing drafts, validation, save and cancel. A failure keeps the draft; editing ends once the save completes.Editing

Connect a query to the request manager with onSubmit: request.submit and onReset: request.reset. Both submit and reset return to the first page, and reset also clears sorting and filters. useTableQuery never issues the first request itself and does not clear fields hidden by collapsing. Editing defaults to single-row mode, where starting a second row returns false; multi-row mode handles rows one by one. Returning false from onSave / onCancel keeps the row in editing, and a thrown error becomes a row error. Drafts do not depend on visible row components; the application updates the data source and explicitly cancels old drafts when switching data sets.

VTable Props ​

Data and structure ​

PropTypeDefaultDescription
dataSourceTRecord[][]Table data source.
paginationfalse | TablePaginationConfigfalsePass {} to enable local or remote pagination; see Pagination.
columnsTableColumnsType<TRecord>[]Column configuration; supports leaf columns, column groups and column placeholder constants.
columnOrderKey[]-Column display order; see Column display and order.
rowKeystring | ((record: TRecord) => Key)'key'Unique row identity. Selection state is recorded by row key, so it must be stable and unique.
childrenColumnNamestring'children'Field name of the child nodes in tree data.
indentSizenumber15Indent width of tree data, in px.
loadDataTableTreeLoadData<TRecord>-(record, { signal }) => Promise<TRecord[]>; lazily loads nodes that provide no children.
isLeaf(record: TRecord) => boolean-Explicitly marks the leaf nodes of a lazy tree; a node that already has children: [] also counts as a leaf.
onTreeLoadError(error: Error, record: TRecord) => void-Lazy loading error notification; can be bound with @tree-load-error.
renderersTableFieldRenderers<TRecord>Built-in mappingOverrides or extends the read-only renderers for valueType per table.

Lazy loading requires stable row keys. Concurrent requests for the same node are deduplicated, and a response that arrives after the node is collapsed goes into the cache without expanding it again. Removing a node, replacing a record that has the same key, or unmounting invalidates the old task, and loaded results are not written into the input data. Selection relationships only cover loaded descendants, and pagination still counts root nodes. See Tree table.

Server-side calculation and requests ​

PropTypeDefaultDescription
manualboolean | TableManualConfigfalsetrue skips local sorting, filtering and pagination slicing; the object form sets sort, filter and pagination separately, with omitted fields treated as false. Controls local computation only; it neither sends nor prevents requests. Header state and the change event keep working; see Choosing a processing mode.

manual only decides which local computations to skip; omitted object fields are treated as false. It neither sends nor prevents network requests. Header state, filter controls and change(filters, sorter, extra) keep working. sorter: true on its own still means local default sorting, so enable manual.sort as well for server-side sorting.

The table can paginate a complete result set locally: pass all records and pagination: { defaultPageSize: 10 }, leave manual.pagination off, and do not connect paging events to a request function. For remote pagination, pass an explicit total and enable manual.pagination to skip local slicing and display the page returned by the server.

The optional useTableRequest provides requests, loading state and refresh methods. The standard fully remote setup binds its manual, pagination and onChange together. The returned manual is a fixed, frozen plain object { sort: true, filter: true, pagination: true }, not a ref; it is equivalent to :manual="true". onChange turns sorting, filtering and paging into requests. Overriding the component's manual does not change this request behavior, and the Hook currently has no per-operation request switches.

For local processing after loading the complete result set, use only the Hook's data, loading and refresh capabilities, with separate local pagination and column state. Mixed modes require application code to route requests by extra.action and keep sorting, filtering and pagination state in sync. See Choosing a processing mode for complete examples.

Visuals and layout ​

PropTypeDefaultDescription
size'small' | 'middle' | 'large''large' for antdv, 'middle' for element-plusTable size, aligned with ant-design-vue naming.
loadingboolean | objectfalseLoading state; for the object form, see options.
borderedbooleanfalseShows borders.
stripedbooleanfalseEnables striped rows.
hoverablebooleantrueEnables row hover highlight.
tableLayout'auto' | 'fixed'-Table layout mode.
showHeaderbooleantrueWhether to show the header.
headerEllipsisbooleanfalseAlso truncates the headers of columns that enable column.ellipsis to a single line with an ellipsis.
classstring-Extra class on the root node.
columnEmptyTextVNodeChild | falsefalseReplaces null or undefined cell values; zero, false and empty strings are kept.

loading ​

Options for the object form of loading.

FieldTypeDefaultDescription
spinningbooleantrueWhether the table is loading.
indicatorVNodeChildPreset indicatorCustom loading indicator.
tipstring-Hint text below the indicator.
delaynumber0Milliseconds to wait before showing; nothing is shown if loading ends during the delay.
wrapperClassNamestring-Class added to the table root element while loading.

Scrolling and positioning ​

PropTypeDefaultDescription
scrollobject-Horizontal and vertical scrolling; see options. Providing y creates a scroll area with a fixed header.
stickyboolean | TableStickyfalseSticky header and summary row; for the object form, see options.
virtualbooleanfalseEnables virtual scrolling; scroll.y must be set as well.
virtualColumnbooleanfalseHorizontal virtualization: renders only the columns inside the viewport; virtual must be enabled as well. It only pays off with many columns; see Virtual scrolling.
rowHeightnumber-Fixed row height (px), effective only with virtual. Declaring it skips all row height measurement, so the visible range is always computed in O(1). Pass it only when every row really has this height; see Virtual scrolling.
getPopupContainer(triggerNode: HTMLElement) => HTMLElement-Mount container for the filter, selection and page-size menus.

scroll ​

FieldTypeDefaultDescription
xnumber | string-Content width of the horizontal scroll area; numbers are treated as px. Horizontal scrolling appears when it exceeds the container width.
ynumber | string-Maximum height of the body; when provided, the header is fixed. 'auto' fills the remaining height of the parent container, which must have a definite height; see Virtual scrolling.
scrollToFirstRowOnChangebooleantrue when pagination is enabledScrolls vertically back to the first row after sorting, filtering or paginating.

sticky ​

Options for the object form of sticky; true equals {}.

FieldTypeDefaultDescription
offsetHeadernumber0Distance between the sticky header and the top of the scroll container, in px.
offsetSummarynumber0Distance between the bottom-fixed summary row and the bottom of the container, in px.
offsetScrollnumber-Reserved in the type; not used in the current version.
getContainer() => Window | HTMLElement-Reserved in the type; not used in the current version.

Themes and locales ​

PropTypeDefaultDescription
uiSlotProps<{ slots: Record<TableSlots, string> }>-Theme slot class overrides for this table instance. For the full slot list, see the ui slot reference.
localeLocaleNameGlobal config or 'zh-CN'Locale identifier used by this table instance.
localesLocaleRegistry{}Extra locale packs registered on this instance.
localeOverridesDeepPartial<VTableGuildTableLocale>{}Partial locale overrides for this instance.

Interactive capabilities ​

PropTypeDefaultDescription
rowSelectionRowSelection<TRecord>-Enables the row selection column; for its fields, see Row selection · RowSelection.
expandableExpandable<TRecord>-Enables expandable rows.
rowDraggablebooleanfalseEnables row drag sorting; see Row drag sorting.
expandedRowKeysKey[]-Controlled list of expanded keys for tree data.
defaultExpandedRowKeysKey[]-Default list of expanded keys for tree data.
defaultExpandAllRowsbooleanfalseExpands all nodes of tree data by default.
onExpand(expanded: boolean, record: TRecord) => void-Expand/collapse callback for tree data.
onExpandedRowsChange(expandedKeys: Key[]) => void-Callback when the expanded keys of tree data change.
transformCellTextTransformCellText<TRecord>-Transforms cell text in one place; opt contains text, column, record and index.
showSorterTooltipboolean | TableTooltipConfigtrue for antdv, false for element-plusTable-level sorter tooltip config; a column-level showSorterTooltip overrides it.
sortDirectionsSortOrder[]['ascend', 'descend']Table-level list of sort directions, used as the default for column-level sortDirections.

Custom structure ​

PropTypeDefaultDescription
rowClassNamestring | RowClassName<TRecord>-Adds a class to body rows.
customRowGetComponentProps<TRecord>-Injects attributes, events and styles into body rows.
customHeaderRow(columns: (ColumnType<TRecord> | ColumnGroupType<TRecord>)[], index?: number) => CellAdditionalProps-Injects attributes, events and styles into header rows.
title(data: TRecord[]) => VNodeChild-Render function for the table title area.
footer(data: TRecord[]) => VNodeChild-Render function for the table footer area.

Cell display enhancements ​

FieldTypeDefaultDescription
copyableboolean | object-Enables the copy button; for the object form, see options.
tooltipstring | TableTooltipConfig-Header help text; for the object form, see options.
valueEnumColumnValueEnum-Maps raw values to display text and status. Accepts an object or a Map.
valueTypestring-Specifies a built-in field render type or a registered custom type.
fieldPropsTableFieldProps | ((context: CustomRenderContext<TRecord>) => TableFieldProps)-Configures the field renderer. Accepts an object or a function that returns the configuration from the cell context.

See Cell display and enums for the object forms of copyable and tooltip; table-level and column-level showSorterTooltip use the same TableTooltipConfig.

Column-level valueEnum?: ColumnValueEnum accepts an object or a Map whose values are text or { text, status }; status can be success, warning, error, processing or default. filters: true builds filter items from the enum. filters: false provides no default filter items. onFilter: false skips local filtering, and onFilter: true uses equality matching. See Cell display and enums.

Column-level valueType?: string selects text / digit / money / date / dateTime / time / dateRange / dateTimeRange / percent / progress / tag or a custom type; fieldProps is an options object or a callback that receives the cell context. createTableRenderers<TRecord>(overrides) merges the built-in and application maps and returns an immutable registry, which you pass through the table's renderers without modifying any global registry. Numbers, money and percentages use Intl, and dates can opt into Intl through dateFormat; tag / progress share the status theme with valueEnum.

transformCellText runs first, and the field renderer consumes the transformed value and the enum label. customRender and valid bodyCell content take precedence, empty values use the existing columnEmptyText, and unknown types fall back to the enum or the raw value. The data contracts for sorting, filtering and default copying stay unchanged. Renderers only provide read-only display. See Field renderers.

Remote dictionaries ​

createTableDictionary({ key, request, cacheTime?, maxEntries? }) creates an instance-isolated cache; useTableDictionary({ dictionary, params?, selectedOptions?, debounceTime? }) turns the shared result into options for host controls, column valueEnum and filters for the complete dictionary. It returns search / reload / cancel plus loading/error state; partial search results do not generate header filters automatically. See Remote dictionaries for the full protocol.

Schema query and column editors ​

VTableQuery takes useTableQuery state, a host control registry, and either fields or columns. It renders the responsive QueryFilter by default. Set layoutType="LightFilter" for popup-based filters. Use validate for host form validation and rootTag="div" inside an existing form. See Schema query.

useTableEditable takes columns, controls and row-editing options, and connects the conditions, transforms, rules and dictionaries of column.editor to the same row draft. Templates bridge through VTableEditCell, and TSX can call renderEditor; when there is no editor content, the read-only fallback is kept. Entering edit mode keeps column widths and row heights by default (layout: 'stable'), and errorPlacement: 'tooltip' keeps validation errors from stretching the row; VTableEditShell gives hand-written controls the same layout. See Column editors.

The controlled dataSource/onChange, records, getOriginal/getDrafts/getValues/validateAll/reset, createRecord/maxRows and the position/cache strategy of add in useTableEdit / useTableEditable serve detail tables inside a main form. validateAll returns the submission snapshot from the same validation pass, including off-screen records held by the client, and does not call save; onChange does not fire on every keystroke. See Detail forms.

VTable instance methods ​

Type the template ref with the public TableInstance. Regular and virtual bodies share the same interface. See Table instance.

MethodTypeDescription
scrollTo(options: TableScrollToOptions) => Promise<boolean>Scrolls to the given row or position; see options. Returns false when the target is not found, the table is not mounted or the arguments are invalid.
retryTreeLoad(key: Key) => Promise<boolean>Retries lazy loading for the node without changing its expanded state.
getTreeLoadError(key: Key) => Error | undefinedReads the lazy loading error of the row.

Positioning only covers loaded, visible records on the current page. Records on other pages, inside collapsed tree nodes or removed by filters return false; change the page, load or expand first, then position. Virtual lists with variable row heights rely on the existing measurement and correction, so the Promise means the positioning has been committed and does not guarantee the final pixel position after images load later.

Column behavior ​

Basic fields ​

FieldTypeDefaultDescription
keyKey-Unique column identity; passing it explicitly is recommended.
titleColumnTitle<TRecord>-Column title; can be text, a VNode or a render function.
dataIndexDataIndex-Data field path, such as 'name' or ['address', 'city'].
widthnumber | string-Column width; numbers are treated as px.
alignAlignType-Alignment of the column content.
ellipsisboolean | { showTitle?: boolean }falseTruncates overflowing cell content with an ellipsis; with showTitle: false, the hover tooltip is not shown.
classNamestring-Extra class for the cells of the column.
colSpannumber-Number of columns the header cell spans.
visiblebooleantrueControls whether the column is shown; see Column display and order.
responsiveBreakpoint[]-Shows the column when the current screen matches any of the breakpoints.

Custom rendering ​

FieldTypeDefaultDescription
customRender(ctx: CustomRenderContext<TRecord>) => VNodeChild | RenderedCell-Custom body cell content. Returning a RenderedCell sets both the content and the cell attributes.
customCellGetComponentProps<TRecord, TRecord>-Injects attributes, events and styles into body cells.
customHeaderCellGetComponentProps<ColumnType<TRecord> | ColumnGroupType<TRecord>, TRecord>-Injects attributes, events and styles into header cells.
ts
import type { TableColumnType } from '@vtable-guild/vtable-guild'

interface NameRow {
  key: number
  name: string
}

const nameColumn: TableColumnType<NameRow> = {
  key: 'name',
  dataIndex: 'name',
  customRender: ({ text, index }) =>
    index === 0
      ? { children: String(text), props: { colSpan: 2, style: { fontWeight: 'bold' } } }
      : String(text),
}

Fixed columns and column resizing ​

FieldTypeDefaultDescription
fixed'left' | 'right' | true-Fixed column position; true is equivalent to 'left'.
resizablebooleanfalseWhether the column width can be adjusted by dragging.
minWidthnumber-Lower bound of a leaf column in auto/fixed layouts and while dragging (a finite, non-negative CSS px value); when unset, only dragging applies a 50px lower bound.
maxWidthnumber-Limits the drag target only; when it is smaller than minWidth, the lower bound wins.

width is a target width and cannot override a valid minWidth. When the minimums add up to more than the container, the table scrolls horizontally, whether or not the columns are resizable. See Minimum column width and layout.

Sorting ​

FieldTypeDefaultDescription
sorterColumnSorter<TRecord>-Enables sorting; supports the default comparison, a custom compare function and a multi-column sort object.
sortOrderSortOrder-Controlled sort direction.
defaultSortOrderSortOrder-Sort direction an uncontrolled column is initialized with.
sortDirectionsSortOrder[]Inherits the table-level settingSort directions available for this column. An empty array falls back to ['ascend', 'descend'].
showSorterTooltipboolean | TableTooltipConfigInherits the table-level settingColumn-level sorter tooltip switch and config.

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

Filtering ​

FieldTypeDefaultDescription
filtersColumnFilterItem[] | boolean-true generates the options from valueEnum, false provides no options; you can also pass a custom array.
onFilterboolean | ((value: string | number | boolean, record: TRecord) => boolean)-true uses the default matching rule, a function defines a custom one, and false skips local filtering.
filterMultiplebooleantrueWhether multiple filter values can be selected.
filteredValueArray<string | number | boolean> | null-Controlled filter values; null and [] both mean controlled with no filter value.
defaultFilteredValueArray<string | number | boolean>-Uncontrolled default filter values.
customFilterDropdownbooleanfalseUses the table-level customFilterDropdown slot.
filterSearchboolean | ((input: string, filter: ColumnFilterItem) => boolean)falseSearch within the filter items.
filterMode'menu' | 'tree''menu'Display mode of the filter items.
filterResetToDefaultFilteredValuebooleanfalseRestores the default filter values on reset.
filterDropdownOpenboolean-Controlled visibility of the filter dropdown.
onFilterDropdownOpenChange(visible: boolean) => void-Callback when the visibility of the filter dropdown changes.
filteredboolean-Controls the highlight state of the filter icon externally; does not change the filtering logic.
filterIcon(opt: { filtered: boolean }) => VNodeChild-Custom filter icon.
filterDropdownVNodeChild | ((props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild)-Column-level custom filter panel; takes precedence over the table-level slot.

Column settings ​

FieldTypeDefaultDescription
hideInSettingbooleanfalseHides the column in the column settings panel.
disableboolean | { checkbox?: boolean; fixed?: boolean; order?: boolean }-Locks column settings actions. Visibility, fixing and ordering can be restricted separately.

Column editors ​

FieldTypeDefaultDescription
editorfalse | TableColumnEditor<TRecord>-Configures the column editor. Read by useTableEditable to connect host controls and row drafts.

Grouped headers ​

FieldTypeDefaultDescription
childrenArray<ColumnType<TRecord> | ColumnGroupType<TRecord>>-Child column configuration. A column that has children acts as a column group.

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

Row Selection ​

rowSelection enables the selection column, with support for multiple selection, single selection, linked selection in tree data, batch-selection menus and controlled selection state.

FieldTypeDefaultDescription
type'checkbox' | 'radio''checkbox'Selection type.
selectedRowKeysKey[]-Controlled selected keys, owned by application code; data source changes never automatically prune them, regardless of preserve.
defaultSelectedRowKeysKey[]-Default selected keys.
onChange(selectedRowKeys: Key[], selectedRows: TRecord[]) => void-Selection change callback; rows follows key order, skipping unavailable records. Without preserve, records come only from the current data source; with preserve, they also include previously cached selected records from other pages.
onSelect(record: TRecord, selected: boolean, selectedRows: TRecord[]) => void-Single-row selection change callback; selectedRows matches the selection result of onChange for the same action.
onSelectMultiple(selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void-Shift multi-selection callback; selectedRows matches onChange for the same action, while changeRows keeps the action traversal order.
onSelectAll(selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void-Select-all change callback; selectedRows matches onChange for the same action, while changeRows keeps the action traversal order.
onSelectInvert(selectedRowKeys: Key[]) => void-Callback when the selection is inverted.
onSelectNone() => void-Callback when the selection is cleared.
getCheckboxProps(record: TRecord) => { disabled?: boolean; name?: string }-Injects attributes into the selection control.
columnWidthnumber | string48Width of the selection column.
fixedboolean | 'left' | 'right'-Fixed position of the selection column.
columnTitlestring | VNodeChild-Header content of the selection column.
renderCell(value: boolean, record: TRecord, index: number, originNode: VNodeChild) => VNodeChild | RenderedCell-Custom selection cell.
checkStrictlybooleantrueWhether parent and child rows are selected independently in tree data.
selectionsboolean | (SelectionItem | SelectionSentinel)[]falseDefault or custom batch selection menu; for the default menu constants, see SelectionSentinel.
hideSelectAllbooleanfalseHides the select-all checkbox and the selection dropdown.
preserveSelectedRowKeysbooleanfalseRetains uncontrolled selected keys when the data source changes and caches loaded selected records for cross-page callbacks; controlled keys remain owned by application code, and unloaded pages are never requested automatically.

For the default batch-selection constants, see SelectionSentinel.

With pagination enabled, the header select-all checkbox and invert selection are limited to the current page. The "Select all data" menu (selections: true or [SELECTION_ALL]) selects all loaded, selectable records after filtering. Controlled selectedRowKeys are owned by application code and are not automatically pruned when the data source changes; uncontrolled mode prunes absent keys when preserve is not enabled. preserveSelectedRowKeys: true also caches selected records across pages so callbacks can return records from earlier pages; unloaded pages are never requested automatically. See Pagination and cross-page selection.

Selection callbacks return rows in key order, skipping keys whose records are unavailable. For the same action, onChange and the single-row, select-all or Shift multi-selection callback share the normalized selection result. See Callback order for ordering and missing-record rules.

Expandable ​

expandable configures expandable row content. The expand props for tree data are configured at the top level of VTable.

FieldTypeDefaultDescription
expandedRowRender(record: TRecord, index: number, indent: number, expanded: boolean) => VNodeChild-Render function for the expanded row content.
expandedRowKeysKey[]-Controlled expanded row keys.
defaultExpandedRowKeysKey[]-Default expanded row keys.
expandRowByClickbooleanfalseExpands a row when the whole row is clicked.
expandIcon(props: { expanded: boolean; record: TRecord; expandable: boolean; onExpand: (record: TRecord, e: Event) => void }) => VNodeChild-Custom expand icon.
onExpand(expanded: boolean, record: TRecord) => void-Expand/collapse callback.
onExpandedRowsChange(expandedKeys: Key[]) => void-Callback when the expanded keys change.
columnWidthnumber | string-Width of the expand column.
fixed'left' | 'right' | true-Fixed position of the expand column; true is equivalent to 'left'.
defaultExpandAllRowsbooleanfalseExpands all rows by default.
rowExpandable(record: TRecord) => boolean-Determines whether a row can be expanded.
showExpandColumnbooleantrueWhether to show the expand column.
expandIconColumnIndexnumber0Zero-based position of the expand column among the application columns. An explicit EXPAND_COLUMN placeholder takes precedence.
columnTitlestring | number''Title of the expand column; can be overridden by #expandColumnTitle.
expandedRowClassNamestring | RowClassName<TRecord>-Class of the expanded row.

Events ​

TRecord is your application's row type. VTableEventProps<TRecord> provides types for template event handlers and event props. If you only need pagination, use pagination.onChange(page, pageSize); in the table event, read the pagination state from extra.pagination.

EventPayloadDescription
change(filters: TableFiltersInfo, sorter: VTableSorterResult<TRecord>, extra: TableChangeExtra<TRecord>) => voidSingle event outlet after sorting, filtering, selection and pagination; extra.action is 'sort', 'filter', 'select' or 'paginate'.
resizeColumn(column: ColumnType<TRecord>, width: number) => voidFires after a column width drag ends.
rowDragEnd(newData: TRecord[], info: RowDragSortInfo) => voidFires when row drag sorting ends and the order has changed; see Row drag sorting.

change keeps its three-argument signature. With pagination enabled it adds extra.pagination; extra.action supports 'sort', 'filter', 'select' and 'paginate'.

For sort, filter and paginate events, extra.currentDataSource is the processed data before pagination; for selection events it is the data displayed on the current page. With remote data it only contains loaded records.

ts
import { ref } from 'vue'
import type { VTableEventProps } from '@vtable-guild/vtable-guild'

interface Row {
  key: number
  name: string
}

const current = ref(1)
const pageSize = ref(10)

const handleChange: NonNullable<VTableEventProps<Row>['onChange']> = (_filters, _sorter, extra) => {
  if (extra.action !== 'paginate' || !extra.pagination) return
  current.value = extra.pagination.current
  pageSize.value = extra.pagination.pageSize
}

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; the column must set customFilterDropdown: true.
customFilterIcon{ column: ColumnType<TRecord>; filtered: boolean }Table-level custom filter icon.
titleTableDataSlotProps<TRecord>Custom title area.
footerTableDataSlotProps<TRecord>Custom footer area.
summary()Custom summary area.
expandColumnTitle()Custom expand column title.
paginationItemTablePaginationSlotPropsRenders application content for the pagination at { slot: 'name' } in pagination.layout.

These are Vue slots. To override structural styles through classes, see the ui slot reference.

VTableSummary ​

VTableSummary renders summary rows.

ComponentDescription
VTableSummarySummary container, placed inside the table's #summary slot.
VTableSummary.RowSummary row; it has no props.
VTableSummary.CellSummary cell.

VTableSummary Props ​

PropTypeDefaultDescription
fixedboolean | 'top' | 'bottom'falseFixes the summary row; true is equivalent to 'bottom'.

VTableSummary.Cell Props ​

PropTypeDefaultDescription
indexnumberRequiredZero-based index of the column the cell is in.
colSpannumber-Number of columns to span.
rowSpannumber-Number of rows to span.
alignAlignType-Content alignment.

Low-level composables ​

These functions support custom headers, draggable rows and themed components. When using VTable column definitions, rowDraggable and theme configuration, the component handles the corresponding wiring.

useColumns ​

useColumns<TRecord extends Record<string, unknown>>(columns) accepts a column getter and returns parsing results that react to column changes. Apply visibility, responsive filtering and ordering in the supplied getter first.

ParameterTypeDescription
columns() => TableColumnsType<TRecord>Reactive column getter supporting groups; selection and expand column sentinels are excluded from the parsed result.
PropertyTypeDescription
leafColumnsComputedRef<TableColumnType<TRecord>[]>Leaf columns recursively flattened from groups.
headerRowsComputedRef<HeaderCellMeta<TRecord>[][]>Grouped headers arranged by depth; HeaderCellMeta describes the inferred structure below and needs no separate import.

Each header in headerRows has the structure below. HeaderCellMeta describes the inferred function return structure; read its fields as shown in the table.

FieldTypeDescription
columnTableColumnType<TRecord> | TableColumnGroupType<TRecord>Column or group represented by the header.
colSpannumberNumber of grid columns occupied by the header.
rowSpannumberNumber of header rows spanned.
colStartnumberZero-based starting grid column.
colEndnumberEnding grid column.
depthnumberZero-based header depth.
isLeafbooleanTrue when the header has no child columns.
leafColumnsTableColumnType<TRecord>[]Leaf columns associated with this header.
leafIndexnumberIndex in the full leafColumns returned by useColumns, or -1 for a group; distinct from the grid column.

useRowDragSort ​

useRowDragSort<TRecord extends Record<string, unknown>>(options) computes a new row order through native HTML5 dragging. Bind the result of getBindings(record, index) to a tr, then write data back in onDrop. Tree nodes move before or after the target row and retain their subtrees.

OptionTypeDefaultDescription
enabled() => booleanRequiredDynamically enable row dragging.
getRowKey(record: TRecord, index: number) => KeyRequiredResolve a stable row key; index is only context for the resolver.
dataSource() => TRecord[]RequiredReturn the current controlled data source.
childrenColumnName() => string | undefined'children'Return the child field name for tree data.
onDrop(newData: TRecord[], info: RowDragSortInfo) => void-Called when a valid drop changes the order; the application writes newData back.
Property or methodTypeDescription
draggingKeyRef<Key | null>Key of the dragged row, or null while idle.
dropTargetRef<RowDragDropTarget | null>Drop target with a key and before/after position.
isDraggingComputedRef<boolean>Whether a drag is in progress.
getBindings(record: TRecord, index: number, userProps?: Record<string, unknown>) => RowDragBindingsCreate tr drag bindings; user handlers run after internal handlers. userProps.draggable=false opts that row out of dragging.

RowDragDropTarget is { key: Key, position: 'before' | 'after' }. RowDragBindings contains the native attributes and events below; disabled rows still forward user handlers. For the table's built-in dragging, see Row drag sorting.

FieldTypeDescription
draggablebooleanNative draggable attribute.
onDragstart(event: DragEvent) => voidBegin a drag and update draggingKey.
onDragover(event: DragEvent) => voidUpdate the drop target.
onDragleave(event: DragEvent) => voidClear target state when leaving a target.
onDrop(event: DragEvent) => voidCompute the reorder result and invoke the configured onDrop.
onDragend(event: DragEvent) => voidClear drag state.

useTheme ​

Call useTheme<T extends ThemeConfig>(componentName, defaultTheme, props, options?) in a custom component's setup. It combines classes in the order default theme, global theme[componentName], then instance ui, and its returned slot functions read the current reactive state.

ParameterTypeDescription
componentNamestringComponent name in the global theme mapping.
defaultThemeMaybeRef<T>Default theme object or ref; T extends ThemeConfig.
propsRecord<string, unknown>Reactive component props, providing variants, ui and class.
optionsUseThemeOptions | undefinedOptional compatibility class configuration.
OptionTypeDescription
compatClassesCompatClassConfig | undefinedCompatibility slots / variants class mapping, used only when global compatClass is enabled.
PropertyTypeDescription
slotsRecord<keyof T['slots'] & string, () => string>A plain object of stable functions that lazily read the current default theme, global overrides and instance ui. Call slots.root() etc. for classes; root also merges props.class.

CompatClassConfig has optional slots?: Record<string, string> and variants?: Record<string, Record<string, Record<string, string>>> fields. Slot keys come from the default theme at creation; a defaultTheme ref can update configuration for existing keys. See Theme overrides for global and instance configuration.

Pagination ​

pagination?: false | TablePaginationConfig is disabled by default; pass {} to enable it. See the pagination configuration reference for the options; scroll.scrollToFirstRowOnChange controls whether changing pages scrolls back to the first row.

Type Declarations ​

Import all types from @vtable-guild/vtable-guild. For base types and the relationships between types, see the Type reference. The summary component props below are helper types used to document the declarations, not names exported by the package.

Props and column configuration
ts
export interface TableProps<TRecord extends object = Record<string, any>> {
  pagination?: false | TablePaginationConfig
  manual?: boolean | TableManualConfig
  columnEmptyText?: VNodeChild | false
  renderers?: TableFieldRenderers<TRecord>
  loadData?: TableTreeLoadData<TRecord>
  isLeaf?: (record: TRecord) => boolean
  onTreeLoadError?: (error: Error, record: TRecord) => void
  dataSource: TRecord[]
  columns: ColumnsType<TRecord>
  columnOrder?: Key[]
  rowKey?: string | ((record: TRecord) => Key)
  loading?:
    | boolean
    | {
        spinning?: boolean
        indicator?: VNodeChild
        tip?: string
        delay?: number
        wrapperClassName?: string
      }
  size?: 'small' | 'middle' | 'large'
  bordered?: boolean
  striped?: boolean
  hoverable?: boolean
  rowDraggable?: boolean
  ui?: SlotProps<{ slots: Record<TableSlots, string> }>
  class?: string
  tableLayout?: TableLayout
  showHeader?: boolean
  headerEllipsis?: boolean
  rowClassName?: string | RowClassName<TRecord>
  customRow?: GetComponentProps<TRecord>
  customHeaderRow?: (
    columns: Array<ColumnType<TRecord> | ColumnGroupType<TRecord>>,
    index?: number,
  ) => CellAdditionalProps
  showSorterTooltip?: boolean | TableTooltipConfig
  sortDirections?: SortOrder[]
  locale?: LocaleName
  locales?: LocaleRegistry
  localeOverrides?: DeepPartial<VTableGuildTableLocale>
  sticky?: boolean | TableSticky
  getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement
  transformCellText?: TransformCellText<TRecord>
  rowSelection?: RowSelection<TRecord>
  expandable?: Expandable<TRecord>
  title?: (data: TRecord[]) => VNodeChild
  footer?: (data: TRecord[]) => VNodeChild
  scroll?: { x?: number | string; y?: number | string; scrollToFirstRowOnChange?: boolean }
  virtual?: boolean
  rowHeight?: number
  virtualColumn?: boolean
  childrenColumnName?: string
  indentSize?: number
  expandedRowKeys?: Key[]
  defaultExpandedRowKeys?: Key[]
  defaultExpandAllRows?: boolean
  onExpand?: (expanded: boolean, record: TRecord) => void
  onExpandedRowsChange?: (expandedKeys: Key[]) => void
}
ts
export interface ColumnType<TRecord extends object = Record<string, any>> {
  key?: Key
  title?: ColumnTitle<TRecord>
  tooltip?: string | TableTooltipConfig
  copyable?: ColumnCopyable<TRecord>
  valueEnum?: ColumnValueEnum
  valueType?: string
  editor?: false | TableColumnEditor<TRecord>
  fieldProps?: TableFieldProps | ((context: CustomRenderContext<TRecord>) => TableFieldProps)
  hideInSetting?: boolean
  disable?: boolean | { checkbox?: boolean; fixed?: boolean; order?: boolean }
  dataIndex?: DataIndex
  width?: number | string
  align?: AlignType
  ellipsis?: boolean | { showTitle?: boolean }
  className?: string
  colSpan?: number
  customRender?: (ctx: CustomRenderContext<TRecord>) => VNodeChild | RenderedCell
  customCell?: GetComponentProps<TRecord, TRecord>
  customHeaderCell?: GetComponentProps<ColumnType<TRecord> | ColumnGroupType<TRecord>, TRecord>
  fixed?: 'left' | 'right' | true
  resizable?: boolean
  minWidth?: number
  maxWidth?: number
  sorter?: ColumnSorter<TRecord>
  sortOrder?: SortOrder
  defaultSortOrder?: SortOrder
  sortDirections?: SortOrder[]
  filters?: ColumnFilterItem[] | boolean
  onFilter?: boolean | ((value: string | number | boolean, record: TRecord) => boolean)
  filterMultiple?: boolean
  filteredValue?: (string | number | boolean)[] | null
  defaultFilteredValue?: (string | number | boolean)[]
  customFilterDropdown?: boolean
  filterSearch?: boolean | ((input: string, filter: ColumnFilterItem) => boolean)
  filterMode?: 'menu' | 'tree'
  filterResetToDefaultFilteredValue?: boolean
  filterDropdownOpen?: boolean
  onFilterDropdownOpenChange?: (visible: boolean) => void
  filtered?: boolean
  filterIcon?: (opt: { filtered: boolean }) => VNodeChild
  filterDropdown?: VNodeChild | ((props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild)
  showSorterTooltip?: boolean | TableTooltipConfig
  visible?: boolean
  responsive?: Breakpoint[]
}
ts
export interface ColumnGroupType<TRecord extends object = Record<string, any>> extends Omit<
  ColumnType<TRecord>,
  | 'dataIndex'
  | 'valueType'
  | 'fieldProps'
  | 'customRender'
  | 'sorter'
  | 'sortOrder'
  | 'defaultSortOrder'
  | 'sortDirections'
  | 'filters'
  | 'onFilter'
  | 'filterMultiple'
  | 'filteredValue'
  | 'defaultFilteredValue'
  | 'customFilterDropdown'
  | 'filterSearch'
  | 'filterMode'
  | 'filterResetToDefaultFilteredValue'
  | 'filterDropdownOpen'
  | 'onFilterDropdownOpenChange'
  | 'filtered'
  | 'filterIcon'
  | 'filterDropdown'
> {
  children: Array<ColumnType<TRecord> | ColumnGroupType<TRecord>>
}
ts
export type ColumnsType<TRecord extends object = Record<string, any>> = Array<
  ColumnType<TRecord> | ColumnGroupType<TRecord> | ColumnSentinel
>
ts
export interface ColumnTitleProps<TRecord extends object = Record<string, any>> {
  sortOrder?: SortOrder
  sortColumn?: ColumnType<TRecord>
  sortColumns?: Array<{ column: ColumnType<TRecord>; order: SortOrder }>
  filters?: Record<string, (string | number | boolean)[] | null>
}
ts
export type ColumnTitle<TRecord extends object = Record<string, any>> =
  | VNodeChild
  | ((props: ColumnTitleProps<TRecord>) => VNodeChild)
ts
export type GetComponentProps<TData, TRecord extends object = Record<string, any>> = (
  data: TData,
  index: number,
  column?: ColumnType<TRecord>,
) => CellAdditionalProps | undefined
ts
export interface CustomRenderContext<TRecord extends object = Record<string, any>> {
  text: unknown
  value: unknown
  record: TRecord
  index: number
  renderIndex: number
  column: ColumnType<TRecord>
}
ts
export interface RenderedCell {
  props?: CellAdditionalProps
  children?: VNodeChild
}
ts
export interface CellAdditionalProps {
  class?: string
  className?: string
  style?: CSSProperties
  colSpan?: number
  rowSpan?: number
  colspan?: number
  rowspan?: number
  onClick?: (event: MouseEvent) => void
  onMouseenter?: (event: MouseEvent) => void
  onMouseleave?: (event: MouseEvent) => void
  [key: string]: unknown
}
ts
export type RowClassName<TRecord = Record<string, any>> = (
  record: TRecord,
  index: number,
  indent: number,
) => string
ts
export type TransformCellText<TRecord extends object = Record<string, any>> = (opt: {
  text: unknown
  column: ColumnType<TRecord>
  record: TRecord
  index: number
}) => unknown
ts
export interface TableSticky {
  offsetHeader?: number
  offsetSummary?: number
  offsetScroll?: number
  getContainer?: () => Window | HTMLElement
}
Selection and expansion
ts
export interface RowSelection<TRecord extends object = Record<string, any>> {
  preserveSelectedRowKeys?: boolean
  type?: RowSelectionType
  selectedRowKeys?: Key[]
  defaultSelectedRowKeys?: Key[]
  onChange?: (selectedRowKeys: Key[], selectedRows: TRecord[]) => void
  onSelect?: (record: TRecord, selected: boolean, selectedRows: TRecord[]) => void
  onSelectMultiple?: (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void
  onSelectAll?: (selected: boolean, selectedRows: TRecord[], changeRows: TRecord[]) => void
  onSelectInvert?: (selectedRowKeys: Key[]) => void
  onSelectNone?: () => void
  getCheckboxProps?: (record: TRecord) => { disabled?: boolean; name?: string }
  columnWidth?: number | string
  fixed?: boolean | 'left' | 'right'
  columnTitle?: string | VNodeChild
  renderCell?: (
    value: boolean,
    record: TRecord,
    index: number,
    originNode: VNodeChild,
  ) => VNodeChild | RenderedCell
  checkStrictly?: boolean
  selections?: boolean | (SelectionItem | SelectionSentinel)[]
  hideSelectAll?: boolean
}
ts
export interface SelectionItem {
  key: string
  text: string | VNodeChild
  onSelect?: (changeableRowKeys: Key[]) => void
}
ts
export interface Expandable<TRecord extends object = Record<string, any>> {
  expandedRowRender?: (
    record: TRecord,
    index: number,
    indent: number,
    expanded: boolean,
  ) => VNodeChild
  expandedRowKeys?: Key[]
  defaultExpandedRowKeys?: Key[]
  expandRowByClick?: boolean
  expandIcon?: (props: {
    expanded: boolean
    record: TRecord
    expandable: boolean
    onExpand: (record: TRecord, e: Event) => void
  }) => VNodeChild
  onExpand?: (expanded: boolean, record: TRecord) => void
  onExpandedRowsChange?: (expandedKeys: Key[]) => void
  columnWidth?: number | string
  fixed?: 'left' | 'right' | true
  defaultExpandAllRows?: boolean
  rowExpandable?: (record: TRecord) => boolean
  showExpandColumn?: boolean
  expandIconColumnIndex?: number
  columnTitle?: string | number
  expandedRowClassName?: string | RowClassName<TRecord>
}
Events and slots
ts
export type TableFiltersInfo = Record<string, (string | number | boolean)[] | null>
ts
export interface SorterResultLike<TRecord extends object = Record<string, any>> {
  column: ColumnType<TRecord> | undefined
  columnKey: Key | undefined
  order: SortOrder
  field: ColumnType<TRecord>['dataIndex']
}
ts
export type VTableSorterResult<TRecord extends object = Record<string, any>> =
  | SorterResultLike<TRecord>
  | Array<SorterResultLike<TRecord>>
ts
export interface TableChangeExtra<TRecord extends object = Record<string, any>> {
  action: 'sort' | 'filter' | 'select' | 'paginate'
  /** Available only when pagination is enabled. */
  pagination?: TablePaginationState
  currentDataSource: TRecord[]
}
ts
export interface RowDragSortInfo {
  draggedKey: Key
  targetKey: Key
  orderedKeys: Key[]
}
ts
export interface VTableEventProps<TRecord extends object = Record<string, any>> {
  onChange?: (
    filters: TableFiltersInfo,
    sorter: VTableSorterResult<TRecord>,
    extra: TableChangeExtra<TRecord>,
  ) => void
  onResizeColumn?: (column: ColumnType<TRecord>, width: number) => void
  onRowDragEnd?: (newData: TRecord[], info: RowDragSortInfo) => void
}
ts
export interface TableBodyCellSlotProps<TRecord extends object = Record<string, any>> {
  text: unknown
  record: TRecord
  index: number
  column: ColumnType<TRecord>
}
ts
export interface TableHeaderCellSlotProps<TRecord extends object = Record<string, any>> {
  title: VNodeChild | undefined
  column: ColumnType<TRecord> | ColumnGroupType<TRecord>
  index: number
}
ts
export interface CustomFilterDropdownSlotProps<TRecord extends object = Record<string, any>> {
  column: ColumnType<TRecord>
  selectedKeys: (string | number | boolean)[]
  setSelectedKeys: (keys: (string | number | boolean)[]) => void
  confirm: (options?: { closeDropdown?: boolean }) => void
  clearFilters: (options?: { confirm?: boolean; closeDropdown?: boolean }) => void
  filters: ColumnFilterItem[]
  visible: boolean
  close: () => void
}
ts
export interface TableDataSlotProps<TRecord extends object = Record<string, any>> {
  data: TRecord[]
}
ts
export interface TableSlotsDecl<TRecord extends object = Record<string, any>> {
  bodyCell?: (props: TableBodyCellSlotProps<TRecord>) => VNodeChild
  headerCell?: (props: TableHeaderCellSlotProps<TRecord>) => VNodeChild
  empty?: () => VNodeChild
  loading?: () => VNodeChild
  customFilterDropdown?: (props: CustomFilterDropdownSlotProps<TRecord>) => VNodeChild
  customFilterIcon?: (props: { column: ColumnType<TRecord>; filtered: boolean }) => VNodeChild
  title?: (props: TableDataSlotProps<TRecord>) => VNodeChild
  footer?: (props: TableDataSlotProps<TRecord>) => VNodeChild
  paginationItem?: (props: TablePaginationSlotProps) => VNodeChild
  summary?: () => VNodeChild
  expandColumnTitle?: () => VNodeChild
}
Pagination
ts
export interface TablePaginationConfig {
  current?: number
  defaultCurrent?: number
  pageSize?: number
  defaultPageSize?: number
  total?: number
  disabled?: boolean
  hideOnSinglePage?: boolean
  showSizeChanger?: boolean
  pageSizeOptions?: (string | number)[]
  totalBoundaryShowSizeChanger?: number
  buildOptionText?: (option: { value: string | number }) => VNodeChild
  showQuickJumper?: boolean | { goButton?: VNodeChild }
  showTotal?: (total: number, range: [number, number]) => VNodeChild
  size?: 'default' | 'small'
  simple?: boolean
  showLessItems?: boolean
  pagerCount?: number
  responsive?: boolean
  itemRender?: (item: {
    page: number
    type: PaginationItemType
    originalElement: VNodeChild
  }) => VNodeChild
  locale?: Partial<VTableGuildPaginationLocale>
  class?: string
  style?: CSSProperties
  position?: TablePaginationPosition[]
  layout?: TablePaginationLayout
  onChange?: (page: number, pageSize: number) => void
  onShowSizeChange?: (current: number, size: number) => void
  'onUpdate:current'?: (current: number) => void
  'onUpdate:pageSize'?: (pageSize: number) => void
}
ts
export interface TablePaginationState {
  current: number
  pageSize: number
  total: number
}
ts
export type TablePaginationPosition =
  | 'topLeft'
  | 'topCenter'
  | 'topRight'
  | 'bottomLeft'
  | 'bottomCenter'
  | 'bottomRight'
  | 'none'
ts
export type PaginationItemType = 'page' | 'prev' | 'next' | 'jump-prev' | 'jump-next'
ts
export type TablePaginationBuiltinLayoutItem =
  | 'total'
  | 'sizes'
  | 'prev'
  | 'pager'
  | 'next'
  | 'jumper'
ts
export type TablePaginationLayoutItem = TablePaginationBuiltinLayoutItem | { readonly slot: string }
ts
export type TablePaginationLayout =
  | readonly TablePaginationLayoutItem[]
  | {
      readonly left?: readonly TablePaginationLayoutItem[]
      readonly right?: readonly TablePaginationLayoutItem[]
    }
ts
export type TablePaginationSlotProps = Readonly<
  TablePaginationState & {
    name: string
    pageCount: number
    range: readonly [number, number]
    disabled: boolean
    position: Exclude<TablePaginationPosition, 'none'>
    region: 'inline' | 'left' | 'right'
  }
>
Summary components
ts
export type SummaryFixed = boolean | 'top' | 'bottom'
ts
/** 文档说明用辅助接口,不是包导出。 */
export interface VTableSummaryProps {
  fixed?: SummaryFixed
}
ts
/** 文档说明用辅助接口,不是包导出。index 是必填的列索引。 */
export interface VTableSummaryCellProps {
  index: number
  colSpan?: number
  rowSpan?: number
  align?: AlignType
}