`。 |
| `expandedRowCell` | 展开内容 `| `。 |
### 树形展开
| Slot | 说明 |
| ------------------------------- | ---------------------- |
| `treeExpandIcon` | 树形展开按钮基础样式。 |
| `treeExpandIconExpanded` | 展开状态。 |
| `treeExpandIconCollapsed` | 折叠状态。 |
| `treeExpandIconSpaced` | 叶子节点占位。 |
| `treeExpandIconDisabled` | 禁用状态。 |
| `treeExpandIconSymbol` | 树形 symbol 容器。 |
| `treeExpandIconSymbolExpanded` | 树形展开 symbol 状态。 |
| `treeExpandIconSymbolCollapsed` | 树形折叠 symbol 状态。 |
### 列宽拖拽
| Slot | 说明 |
| -------------- | -------------- |
| `resizeHandle` | 列宽拖拽手柄。 |
---
## Variant 列表
除了直接的 slot 覆盖,主题还通过 variant 控制条件样式。它们可以通过 props 控制,也可以通过全局 `theme.table.variants` 和 `theme.table.defaultVariants` 调整。
| Variant | 值 | 默认值 | 影响的 Slot |
| ----------- | ---------------------------- | ------- | ------------------------------------------------------------- |
| `size` | `small` / `middle` / `large` | `large` | `th`、`td`、`title`、`footer`、`summaryCell` 的 padding |
| `bordered` | `true` / `false` | `false` | `root`、`th`、`td`、`tbody`、`title`、`footer`、`summaryCell` |
| `striped` | `true` / `false` | `false` | `td`,偶数行背景 |
| `hoverable` | `true` / `false` | `true` | `td`,行 hover 背景 |
| `loading` | `true` / `false` | 无 | `table`,半透明和禁交互状态 |
## 进一步阅读
- [三层主题覆盖](/guide/theme-overrides)
- [Table CSS 变量参考](/guide/theme-tokens)
- [预设与语言](/guide/presets-and-locales)
- [API Reference](/guide/api-reference)
---
# 虚拟滚动
虚拟滚动是 vtable-guild 最值得优先关注的增强能力之一。对于长列表页面,它的价值不是“多一个开关”,而是让你不必再维护另一套大数据量表格方案。
## 在线示例:10 万行
下面这张表默认装载 **10 万行**真实数据(页面内运行时生成,不是分页假象)。滚动它,同时留意 DOM 里始终只有可视区的十几行。左侧两列仍然固定,「评分」列仍然可以排序。
```vue
// @/demos/virtualization/large.vue
{{ summary }}
```
## 怎么开启
虚拟滚动需要同时满足两个条件:
- `virtual` 为 `true`
- `scroll.y` 提供一个有效高度
```vue
```
## 关键边界
- 只写 `virtual`,不写 `scroll.y`,不会真正启用虚拟滚动
- `rowKey` 需要保持稳定,否则滚动窗口复用时容易出现状态错位
- 虚拟滚动提升的是渲染性能,不会替代服务端分页、慢查询优化或大对象计算优化
## 定高快路径 `rowHeight`
默认路径支持**不定行高**:每行挂载后实测高度,再据此算可视区。代价是挂载和滚动都要维护一张位置表。
如果你的每一行高度确实相同,可以显式声明 `rowHeight`,跳过全部行高测量——可视区计算恒为 O(1),
挂载与滚动开销不再随总行数增长。
```vue
```
- 仅在 `virtual` 下生效,单位 px
- **前提是每行实际高度确实等于该值**。存在换行文本、`ellipsis: false` 的长内容或自定义高度渲染时,
不要传这个 prop,交给默认的实测路径
- 我们刻意不做自动探测:从 `size` 预设猜行高在长文本换行时会静默算错,而错误表现为行错位或空隙,
很难归因,所以要求你主动声明
- dev 构建会实测首行高度,与声明值相差超过 1px 时在控制台告警;生产构建跳过这次测量
## 自动高度 `scroll.y: 'auto'`
`scroll.y` 传数字表示**固定的**表体视口高度;传 `'auto'` 则表示**自动适应内容区**:
表格充满父容器,表体高度 = 父容器可用高度 − 表头 − 固定 summary,由组件内部测量扣减。
你不必再自己监听 resize、也不必去读表头高度来手工扣减——浏览器 Ctrl+滚轮缩放、
窗口拖拽、父布局变化都会自动跟随。下方演示可在「块级父」与「flex 布局 + 兄弟节点」
两种父容器形态之间切换。
```vue
// @/demos/virtualization/auto-height.vue
取消勾选后拖动高度滑杆:容器缩了表格不跟随(被裁切),底部摘要栏被挤出可视区——flex 子项默认
min-height: auto,拒绝收缩
▦ 兄弟节点:统计栏(flex-shrink: 0)
▦ 兄弟节点:底部摘要栏
```
### 父容器要求
`'auto'` 依赖一条**确定的高度链**:
- 普通块级父容器:父容器需要有确定高度(如 `height: 400px`),且 VTable 是它的专用填充子项
- flex 布局:允许存在兄弟节点,但高度链必须确定,且 VTable 的可收缩祖先需要 `min-height: 0`——
否则高度链在那里断掉,测不到可用高度
- 内容自然撑高的父容器(高度不确定)不适用;dev 构建下连续测不到可用高度会在控制台提示
flex 布局 + 兄弟节点的写法:把上方演示切到「flex 布局 + 兄弟节点」后,取消勾选
`min-height: 0` 并拖动高度滑杆,可以现场复现高度链断裂——flex 子项默认 `min-height: auto`
会拒绝收缩,容器缩了表格却不跟随:表体被裁切、底部摘要栏被挤出可视区。
### 行为细节
- 少量数据按内容自然收缩(maxHeight 语义),超出可用区域后才出现纵向滚动
- 普通模式与虚拟模式都支持;虚拟模式下即使 `showHeader: false` 也保持可滚动的表体
- 数字 `scroll.y` 行为完全不变;非虚拟模式下其他 CSS 字符串(`'100%'`、`calc(...)`)仍原样生效
- **虚拟模式下的字符串约束**:仅兼容正数 px(如 `'480px'`,dev 会提示改用数字);
`'100%'`、`'50vh'`、`calc(...)`、负数等无法可靠解析的值会告警并回落 400px 视口——
保持虚拟可用,而不是回落全量渲染的普通表体(万行宽表上那是秒级冻结)
## 横向虚拟化 `virtualColumn`
上面那个开关虚拟化的是**行**。列很多时(百列量级)瓶颈会换一个地方:每个可见单元格
都是一个组件实例,12 行 × 200 列就是 2,400 个,滚动时每帧都要重新走一遍。
`virtualColumn` 把可见单元格数从「行 × 总列数」降到「行 × 可视列数」。
```vue
```
实测 1 万行 × 200 列:可视列数 200 → 13,连续滚动 longtask 4,391ms → **0**,
排序切换 126ms → 75ms,DOM 节点数 3,659 → 1,415。完整数字与方法见[性能文档](https://github.com/parade0393/vtable-guild/blob/master/docs/performance.md)。
**默认关闭,而且应该保持关闭**,除非你的列数真的很多:6 列时它既无收益也无代价
(实测完全持平),但会多一次表头测量。
### 在线示例:1 万行 × 200 列
下面这张表 200 个叶子列,两端各有固定列。左右滚动时留意「渲染列数」——开关一关,
它立刻从十几跳回 200,而这 200 个单元格每行都要重建一次。`C1` 列仍然可以排序。
```vue
// @/demos/virtualization/wide-columns.vue
{{ ROW_COUNT.toLocaleString() }} 行 × {{ LEAF_COUNT }} 列 · {{ summary }}
在表格上按住 Shift 滚动滚轮(触控板直接左右滑)横向滚动,注意上面的「渲染列数」。
关掉开关后它会立刻跳回 {{ LEAF_COUNT }}——那才是每行真正要重建的单元格数。
```
### 什么时候它会被忽略
不满足下列任一前提时,`virtualColumn` 会被忽略、表体回落到渲染全部列,
dev 构建会在控制台给出原因:
- 没有开启 `virtual`
- 列上有 `customCell` / `customRender`——它们可能返回 `colSpan` / `rowSpan`,
单元格合并会让某个 ` | ` 缺席,进而破坏列宽对齐(虚拟模式本就不支持合并)
- 固定列没有分列两端:左固定必须连成前缀、右固定必须连成后缀
- `showHeader: false` 且存在非数字列宽——此时没有表头可供实测,也算不出来
### 已知边界
- 列宽不要求你声明数字:`auto`、百分比都支持,因为宽度是从表头**量**出来的
- 首帧会先渲染全部列,量到宽度后才收窄。所以它优化的是**滚动与更新**,
首次渲染耗时基本不变
- 列滚出窗口时,挂在该列表头上的筛选面板 / tooltip 会随之卸载
- 表头本身不虚拟化:列数极多时仍会渲染全部表头单元格(一次性成本,非每行)
## 什么时候用
- 列表行数很多,滚动明显卡顿
- 你希望在同一张表里保留列定义、主题和交互能力,而不是切换到另一种列表组件
- 当前页面的主要瓶颈来自 DOM 数量,而不是接口本身
## 自己量一遍
不必相信这里的任何说法——[性能对照页](/perf/)可以在你自己的机器上,把 vtable-guild、
ant-design-vue Table、antdv-next、el-table-v2 与 vxe-table 放在**同一批数据、同一套列配置**
下跑一遍(1k / 1 万 / 10 万行 × 6 / 50 / 200 列),给出渲染耗时、DOM 节点数与内存,
并一键导出结果。采集方法与已知的不对等之处都写在页面上。
## 相关页面
- [固定列](/guide/fixed-columns)
- [功能对比总览](/comparison/)
---
# 为什么选择 vtable-guild
vtable-guild 不是一套全新的 UI 体系,而是给已经在使用 ant-design-vue 或 element-plus 的项目提供一条更顺手的表格替换路径。
它的目标很明确:保留你熟悉的列定义、排序筛选和业务集成方式,同时补上原表格在大数据量、列布局控制和主题扩展上的短板。
## 目标用户
这套库更适合以下场景:
- 你的项目已经使用 ant-design-vue 或 element-plus,希望表格视觉与整体 UI 体系保持一致
- 你不想继续为虚拟滚动、列宽拖拽、条纹行和 hover 状态维护额外封装
- 你需要一套能在全局、业务线和单实例三层同时控制样式的主题机制
- 你希望迁移成本可控,而不是把现有表格页面全部推倒重写
## 它解决的核心问题
### 1. 原表格能力不够用
业务表格变复杂之后,痛点往往不是“能不能渲染表格”,而是:
- 大数据量下滚动和渲染体验差
- 列宽需要用户现场调整,但原表格和业务封装之间还要再补一层约定
- 条纹行、hover 行、边框和空态样式主要靠额外 CSS 覆盖
- 同一套业务代码要接入不同视觉体系时,样式调整成本高
### 2. 继续在原表格上堆补丁会越来越重
现有业务里最贵的部分通常不是模板语法本身,而是列配置、数据处理、事件联动和页面约定。vtable-guild 的价值在于尽量保留这些使用方式,把增强能力做进表格内部,而不是继续把复杂度压给业务层。
## 什么时候适合优先考虑它
- 你来自 ant-design-vue,希望在不改掉整套表格心智的前提下补齐虚拟滚动和主题系统
- 你来自 element-plus,希望用统一的 columns + props 模型替代表格能力分散的接入方式
- 你已经开始为同一类表格重复写 CSS hack、滚动补丁或主题封装
## 什么时候不适合
如果你的页面只是一个非常简单的数据展示表,没有性能、列布局、主题切换或复杂交互需求,继续使用现有 UI 库自带表格通常更省事。
vtable-guild 更适合中大型业务表格,而不是为了“替换而替换”。
---
# 增强与独有能力
这一页只聚焦“相对原表格方案额外得到什么”,不重复完整教程。需要具体使用方式时,请跳到对应指南页。
## 更顺手的 API
### 尺寸命名与 ant-design-vue 一致
表格尺寸沿用 `small`、`middle`、`large`,和 ant-design-vue 完全相同——从 antdv 迁过来时这一项不用改。默认值是 `large`。
### TypeScript 使用链路更完整
VTable 提供明确的列类型、行数据类型、事件参数类型,以及主题 key 和 slot key 的类型边界,适合在业务代码里长期维护。
### 样式覆盖路径更清晰
除了 Vue slot,本库把样式覆盖拆成三层:
- `themePreset`
切换整体视觉基线
- 全局 `theme`
统一应用级规则
- 实例级 `ui`
处理单表例外
对应说明见 [三层主题覆盖](/guide/theme-overrides)。
## 更直接的表格能力
### 虚拟滚动
通过 `virtual` 配合 `scroll.y` 直接启用,适合长列表和性能敏感页面。详见 [虚拟滚动](/guide/virtualization)。
### 列设置:列显示与列顺序
`column.visible` 控制列是否显示、`columnOrder` 按列 key 重排顶层列,都是受控属性——显示状态可以持久化成用户偏好。antdv / element-plus 的原生表格都需要自行拼装这类「列设置」面板。详见 [列显示与列顺序](/guide/column-display)。
### 行拖拽排序
`rowDraggable` 开启原生 HTML5 整行拖拽,拖放结束通过 `rowDragEnd` 返回重排后的数据(受控模式),不需要再引入第三方拖拽库。详见 [行拖拽排序](/guide/row-drag-sort)。
### 更直接的视觉状态开关
- `striped`
条纹行
- `hoverable`
行 hover 高亮
- `bordered`
边框模式
这些状态都可以直接通过 props 或主题配置开启,不需要再拆散到业务 CSS 里。
### 多预设支持
当前内置 `antdv` 和 `element-plus` 两套预设,可让同一套表格逻辑接入不同 Vue UI 体系。详见 [预设与语言](/guide/presets-and-locales)。
## 继续阅读
- [功能对比总览](/comparison/)
- [虚拟滚动](/guide/virtualization)
- [列宽拖拽](/guide/column-resize)
- [列显示与列顺序](/guide/column-display)
- [行拖拽排序](/guide/row-drag-sort)
- [三层主题覆盖](/guide/theme-overrides)
---
# 功能对比总览
这一页只回答一个问题:如果你已经在使用 ant-design-vue Table 或 element-plus Table,vtable-guild 多了什么,迁移成本主要落在哪里。
## 功能矩阵
| 能力 | ant-design-vue | element-plus | vtable-guild |
| -------------------- | ---------------------------------------- | ---------------------------------- | -------------------------------------------------- |
| 常见列配置与交互写法 | 支持 | 主要依赖 `el-table-column` | 支持,设计更贴近 ant-design-vue |
| 虚拟滚动 | 不支持 | 有独立 Virtualized Table 方案 | 原生支持,直接配合 `virtual` 和 `scroll.y` 使用 |
| 滚动体验优化 | 默认滚动体验 | 体验更好,可作参考 | 在 antdv 预设下做了额外打磨,方向参考 element-plus |
| 列宽拖拽 | 支持 `resizable`、`minWidth`、`maxWidth` | 支持,通常在 border 模式里使用 | 支持,并沿用接近 antdv 的字段心智 |
| 条纹行 | 主要靠 `rowClassName` | 直接使用 `stripe` | 直接使用 `striped` |
| hover 开关 | 没有独立开关 | 没有独立开关 | 直接使用 `hoverable` |
| 边框模式 | 支持 | 支持 | 支持,直接使用 `bordered` |
| 主题预设切换 | 不支持 | 不支持 | 支持 `antdv` / `element-plus` |
| slot 级样式覆盖 | 主要依赖 CSS 覆盖 | 主要依赖 class、style 和 slot 组合 | 通过 `ui` 和全局 `theme` 精确覆盖 |
| 尺寸命名 | `small / middle / large` | `large / default / small` | `small / middle / large`,与 antdv 一致 |
| 内置 locale 预设 | 依赖组件库全局配置 | 依赖组件库全局配置 | 内置 locale 并支持局部覆盖 |
## 结论
- 如果你只需要一张基础表格,原生表格通常已经够用
- 如果你来自 ant-design-vue,vtable-guild 的主要价值是把虚拟滚动、主题系统和更直接的视觉状态开关收进同一套表格模型
- 如果你来自 element-plus,vtable-guild 的主要价值是把表格能力统一到同一套 columns + props 模型里,而不是在普通表格和独立增强方案之间切换
## 继续阅读
- [增强与独有能力](/comparison/enhancements)
- [为什么选择 vtable-guild](/guide/why)
- [从 ant-design-vue 迁移](/guide/migration-from-antd)
---
# 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](/guide/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
| Prop | Type | Default | Description |
| -------------------- | ---------------------------------------------------------------- | ------------ | ---------------------------------------------------------------------------- |
| `dataSource` | `TRecord[]` | `[]` | Table data source. |
| `columns` | [`TableColumnsType`](/guide/type-reference#columnstype) | `[]` | Column configuration: leaf columns, column groups and sentinel constants. |
| `columnOrder` | [`Key[]`](/guide/type-reference#key) | - | Column display order. See [column display](/guide/column-display) (Chinese). |
| `rowKey` | `string \| (record) => Key` | - | Unique row identity; passing it explicitly is recommended. |
| `childrenColumnName` | `string` | `'children'` | Child field name for tree data. |
| `indentSize` | `number` | `15` | Tree data indent width in px. |
### Visuals and layout
| Prop | Type | Default | Description |
| ---------------- | -------------------------------- | --------- | ---------------------------------------------------------------------- |
| `size` | `'small' \| 'middle' \| 'large'` | `'large'` | Table size, aligned with ant-design-vue naming. |
| `loading` | `boolean \| object` | `false` | Loading state; the object form accepts `spinning`, `indicator`, `tip`. |
| `bordered` | `boolean` | `false` | Show borders. |
| `striped` | `boolean` | `false` | Zebra striping. |
| `hoverable` | `boolean` | `true` | Row hover highlight. |
| `tableLayout` | `'auto' \| 'fixed'` | - | Table layout mode. |
| `showHeader` | `boolean` | `true` | Whether to show the header. |
| `headerEllipsis` | `boolean` | `false` | Also ellipsize headers of columns with `column.ellipsis`. |
| `class` | `string` | - | Extra class on the root node. |
### Scrolling and positioning
| Prop | Type | Default | Description |
| ------------------- | ------------------------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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. |
| `sticky` | `boolean \| TableSticky` | `false` | Sticky header, summary or horizontal scrollbar config. |
| `virtual` | `boolean` | `false` | Enable virtual scrolling; requires `scroll.y`. |
| `virtualColumn` | `boolean` | `false` | Horizontal virtualization: render only columns in the viewport; requires `virtual`. Pays off with many columns, see [virtualization](/guide/virtualization) (Chinese). |
| `rowHeight` | `number` | - | 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
| Prop | Type | Default | Description |
| ----------------- | -------------------------------------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `ui` | `SlotProps` | - | Theme slot class overrides for this table instance. See the [ui slot reference](/guide/ui-slots-reference) (Chinese). |
| `locale` | [`LocaleName`](/guide/type-reference#localename) | global config or `'zh-CN'` | Locale identifier for this table instance. |
| `locales` | [`LocaleRegistry`](/guide/type-reference#localeregistry) | `{}` | Extra locale packs registered on this instance. |
| `localeOverrides` | `DeepPartial` | `{}` | Partial locale overrides for this instance. |
### Interactive capabilities
| Prop | Type | Default | Description |
| ------------------------ | ------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------- |
| `rowSelection` | [`RowSelection`](/guide/type-reference#rowselection) | - | Enable the selection column. |
| `expandable` | [`Expandable`](/guide/type-reference#expandable) | - | Enable expandable rows. |
| `rowDraggable` | `boolean` | `false` | Enable row drag sorting, see [row drag sort](/guide/row-drag-sort) (Chinese). |
| `expandedRowKeys` | `Key[]` | - | Controlled expanded keys for tree data. |
| `defaultExpandedRowKeys` | `Key[]` | - | Default expanded keys for tree data. |
| `defaultExpandAllRows` | `boolean` | `false` | Expand 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`. |
| `showSorterTooltip` | `boolean` | `true` | Table-level sorter tooltip switch, overridable per column. |
| `sortDirections` | [`SortOrder[]`](/guide/type-reference#sortorder) | - | Table-level sort direction list, used as the default for columns. |
### Custom structure
| Prop | Type | Default | Description |
| ----------------- | ------------------------------------------ | ------- | ---------------------------------------------------- |
| `rowClassName` | `string \| RowClassName` | - | Extra class for body rows. |
| `customRow` | `GetComponentProps` | - | 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
| Field | Type | Default | Description |
| ------------ | -------------------------------------------------- | ------- | ----------------------------------------------------------------------------------- |
| `key` | [`Key`](/guide/type-reference#key) | - | Unique column identity; passing it explicitly is recommended. |
| `title` | `VNodeChild \| function` | - | Column title: text, VNode or render function. |
| `dataIndex` | [`DataIndex`](/guide/type-reference#dataindex) | - | Data field path, e.g. `'name'` or `['address', 'city']`. |
| `width` | `number \| string` | - | Column width; numbers are treated as px. |
| `align` | [`AlignType`](/guide/type-reference#aligntype) | - | Cell content alignment. |
| `ellipsis` | `boolean \| { showTitle?: boolean }` | `false` | Ellipsize overflowing cell content; `showTitle: false` disables the hover tooltip. |
| `className` | `string` | - | Extra class for the column's cells. |
| `colSpan` | `number` | - | Header cell colSpan. |
| `visible` | `boolean` | `true` | Whether the column is shown, see [column display](/guide/column-display) (Chinese). |
| `responsive` | [`Breakpoint[]`](/guide/type-reference#breakpoint) | - | Show the column when any listed breakpoint matches the screen. |
### Custom rendering
| Field | Type | Default | Description |
| ------------------ | ------------------------------------------------- | ------- | ------------------------------------------------------------------------ |
| `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
| Field | Type | Default | Description |
| ----------- | --------------------------- | ------- | -------------------------------------------- |
| `fixed` | `'left' \| 'right' \| true` | - | Fixed side; `true` equals `'left'`. |
| `resizable` | `boolean` | `false` | Whether the column width is drag-adjustable. |
| `minWidth` | `number` | `50` | Minimum width while resizing. |
| `maxWidth` | `number` | - | Maximum width while resizing. |
### Sorting
| Field | Type | Default | Description |
| ------------------- | ------------------------------------------------------------- | ----------------------- | -------------------------------------------------------------------------- |
| `sorter` | [`ColumnSorter`](/guide/type-reference#columnsorter) | - | Enable sorting: default compare, custom compare fn or multi-column object. |
| `sortOrder` | [`SortOrder`](/guide/type-reference#sortorder) | - | Controlled sort order. |
| `defaultSortOrder` | [`SortOrder`](/guide/type-reference#sortorder) | - | Uncontrolled default order, effective on first render only. |
| `sortDirections` | `SortOrder[]` | `['ascend', 'descend']` | Sort directions available for this column. |
| `showSorterTooltip` | `boolean` | inherits table config | Column-level sorter tooltip switch. |
Table-level `sortDirections` and `showSorterTooltip` act as defaults; column-level config wins.
### Filtering
| Field | Type | Default | Description |
| ----------------------------------- | -------------------------------------------------------------- | -------- | -------------------------------------------------------------- |
| `filters` | [`ColumnFilterItem[]`](/guide/type-reference#columnfilteritem) | - | Filter menu items; renders the filter icon in the header. |
| `onFilter` | `(value, record) => boolean` | - | Filter function; return `true` to keep the row. |
| `filterMultiple` | `boolean` | `true` | Whether multiple filter values can be picked. |
| `filteredValue` | `Array \| null` | - | Controlled filter values. |
| `defaultFilteredValue` | `Array` | - | Uncontrolled default filter values. |
| `customFilterDropdown` | `boolean` | `false` | Use the table-level `customFilterDropdown` slot. |
| `filterSearch` | `boolean \| (input, filter) => boolean` | `false` | Search within filter items. |
| `filterMode` | `'menu' \| 'tree'` | `'menu'` | Filter item presentation mode. |
| `filterResetToDefaultFilteredValue` | `boolean` | `false` | Reset restores the default filter values. |
| `filterDropdownOpen` | `boolean` | - | Controlled filter dropdown visibility. |
| `onFilterDropdownOpenChange` | `(visible) => void` | - | Filter dropdown visibility callback. |
| `filtered` | `boolean` | - | Externally control the filter icon highlight; does not filter. |
| `filterIcon` | `({ filtered }) => VNodeChild` | - | Custom filter icon. |
| `filterDropdown` | `VNodeChild \| (props) => VNodeChild` | - | Column-level custom filter panel; overrides the table slot. |
### Column groups
| Field | Type | Default | Description |
| ---------- | -------------------------------------------------------- | ------- | ------------------------------------------------------------- |
| `children` | `Array \| ColumnGroupType>` | - | 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.
| Field | Type | Default | Description |
| ------------------------- | ------------------------------------------------------------------ | ------------ | ------------------------------------------------ |
| `type` | `'checkbox' \| 'radio'` | `'checkbox'` | Selection type. |
| `selectedRowKeys` | `Key[]` | - | Controlled selected keys. |
| `defaultSelectedRowKeys` | `Key[]` | - | 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. |
| `columnWidth` | `number \| string` | - | Selection column width. |
| `fixed` | `boolean \| 'left' \| 'right'` | - | Fixed position of the selection column. |
| `columnTitle` | `string \| VNodeChild` | - | Selection column header content. |
| `renderCell` | `(value, record, index, originNode) => VNodeChild \| RenderedCell` | - | Custom selection cell. |
| `checkStrictly` | `boolean` | `true` | Parent/child independent selection in tree data. |
| `selections` | `boolean \| array` | `false` | Default or custom batch-selection menu. |
| `hideSelectAll` | `boolean` | `false` | Hide the select-all checkbox and dropdown. |
| `preserveSelectedRowKeys` | `boolean` | `false` | Keep selected keys when the data source changes. |
Default batch-selection constants: see [SelectionSentinel](/guide/type-reference#selectionsentinel) (Chinese).
## Expandable
`expandable` configures expandable row content. Tree-data expand props live at the `VTable` top level.
| Field | Type | Default | Description |
| ------------------------ | ------------------------------------------------- | ------- | ------------------------------------------------------- |
| `expandedRowRender` | `(record, index, indent, expanded) => VNodeChild` | - | Expanded row content render function. |
| `expandedRowKeys` | `Key[]` | - | Controlled expanded row keys. |
| `defaultExpandedRowKeys` | `Key[]` | - | Default expanded row keys. |
| `expandRowByClick` | `boolean` | `false` | Expand on full-row click. |
| `expandIcon` | `(props) => VNodeChild` | - | Custom expand icon. |
| `onExpand` | `(expanded, record) => void` | - | Expand/collapse callback. |
| `onExpandedRowsChange` | `(expandedKeys) => void` | - | Expanded-keys callback. |
| `columnWidth` | `number \| string` | - | Expand column width. |
| `fixed` | `'left' \| 'right' \| true` | - | Fixed position of the expand column; `true` = `'left'`. |
| `defaultExpandAllRows` | `boolean` | `false` | Expand all rows by default. |
| `rowExpandable` | `(record) => boolean` | - | Whether a row is expandable. |
| `showExpandColumn` | `boolean` | `true` | Whether to show the expand column. |
| `expandedRowClassName` | `string \| RowClassName` | - | Class for expanded rows. |
## Events
| Event | Payload | Description |
| -------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `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](/guide/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
| Slot | Payload type | Description |
| ---------------------- | ----------------------------------------------------------------------------------------------- | -------------------------------- |
| `bodyCell` | [`TableBodyCellSlotProps`](/guide/type-reference#tablebodycellslotprops) | Custom cell content. |
| `headerCell` | [`TableHeaderCellSlotProps`](/guide/type-reference#tableheadercellslotprops) | Custom header cell content. |
| `empty` | `()` | Custom empty state. |
| `loading` | `()` | Custom loading state. |
| `customFilterDropdown` | [`CustomFilterDropdownSlotProps`](/guide/type-reference#customfilterdropdownslotprops) | Table-level custom filter panel. |
| `customFilterIcon` | `{ column, filtered }` | Table-level custom filter icon. |
| `title` | [`TableDataSlotProps`](/guide/type-reference#tabledataslotprops) | Custom title area. |
| `footer` | [`TableDataSlotProps`](/guide/type-reference#tabledataslotprops) | Custom footer area. |
| `summary` | `()` | Custom summary area. |
> These are Vue slots. To restyle structure via classes, see the [ui slot reference](/guide/ui-slots-reference) (Chinese).
## VTableSummary
`VTableSummary` renders summary rows.
| Component | Common props | Description |
| -------------------- | -------------------------------------- | --------------------------------------------------------------- |
| `VTableSummary` | `fixed` | Summary container; `fixed` accepts `true`, `'top'`, `'bottom'`. |
| `VTableSummary.Row` | - | Summary row. |
| `VTableSummary.Cell` | `index`, `colSpan`, `rowSpan`, `align` | Summary cell. |
## Related pages
- [Type reference](/guide/type-reference) (Chinese)
- [ui slot reference](/guide/ui-slots-reference) (Chinese)
- [Sorting](/guide/sorting) (Chinese)
- [Filtering](/guide/filtering) (Chinese)
---
# Getting started
This page does one thing: get your first vtable-guild table running in an existing Vue 3 + Vite project as quickly as possible.
If you are already using ant-design-vue or element-plus, finish the initialization here first, then continue with the migration and theming pages (currently Chinese-only).
## Requirements
- Node `^20.19.0` or `>=22.12.0`
- pnpm `>=10.28.0`
- Vue `^3.5.0`
- Vite `^5` or newer
## Install
The component does not require Tailwind CSS in the host project. Install the package:
```bash
pnpm add @vtable-guild/vtable-guild
```
## Configure the style entry
vtable-guild supports three style modes: `prebuilt`, `tailwind3` and `tailwind4`.
### prebuilt
If your project does not use Tailwind CSS, import the prebuilt stylesheet entry directly.
For example, in `src/main.css`:
```css
@import '@vtable-guild/vtable-guild/css/style';
```
This entry ships pre-generated utilities for the library's internal styles. You do not need to install Tailwind CSS, configure `@tailwindcss/vite`, or scan this library's sources.
### tailwind3
If your project uses Tailwind CSS 3, use the Tailwind 3 entry and add the library's preset to your Tailwind config:
```js
import vtableGuildTailwind3Preset from '@vtable-guild/vtable-guild/tailwind3-preset'
export default {
content: [
'./index.html',
'./src/**/*.{vue,ts,tsx,js,jsx}',
'./node_modules/@vtable-guild/**/*.{js,mjs}',
],
presets: [vtableGuildTailwind3Preset],
}
```
```css
@import '@vtable-guild/vtable-guild/css/tailwind3';
@tailwind base;
@tailwind components;
@tailwind utilities;
```
```ts
app.use(createVTableGuild({ cssMode: 'tailwind3' }))
```
### tailwind4
If your project uses Tailwind CSS 4, use the Tailwind 4 entry:
```bash
pnpm add -D tailwindcss @tailwindcss/vite
```
```ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [vue(), tailwindcss()],
})
```
```css
@import 'tailwindcss';
@import '@vtable-guild/vtable-guild/css/tailwind4';
```
```ts
app.use(createVTableGuild({ cssMode: 'tailwind4' }))
```
`@vtable-guild/vtable-guild/css/style`, `@vtable-guild/vtable-guild/css/tailwind3` and `@vtable-guild/vtable-guild/css/tailwind4` all include:
- the default `antdv` preset
- the `element-plus` preset
- theme tokens
- the base styles required by the components
Switching presets requires no extra CSS.
In prebuilt mode the library's internal utility classes are emitted with the `vtg-` prefix. In Tailwind 3/4 modes internal classes stay unprefixed. See [package consumption](/guide/package-consumption) (Chinese) for the full rules.
## Initialize the plugin
Import the global stylesheet and initialize the plugin in your entry file.
For example, in `src/main.ts`:
```ts
import { createApp } from 'vue'
import App from './App.vue'
import { createVTableGuild } from '@vtable-guild/vtable-guild'
import './main.css'
const app = createApp(App)
app.use(createVTableGuild())
app.mount('#app')
```
The default preset is `antdv`. To switch to the element-plus look, set `themePreset`:
```ts
app.use(
createVTableGuild({
themePreset: 'element-plus',
}),
)
```
## Minimal example
```vue
```
## Where to go next
- To estimate migration cost: read [migrating from ant-design-vue](/guide/migration-from-antd) (Chinese)
- To unify the visual system: [three-layer theme overrides](/guide/theme-overrides) and [Table CSS variables](/guide/theme-tokens) (Chinese)
- To inspect the full API: the [English API Reference](/en/guide/api-reference)
---
# Guide
This guide is for developers who already use ant-design-vue or element-plus in a Vue 3 project. It focuses on whether replacing your current table is worth it, how to integrate vtable-guild, and how to use it in high-frequency scenarios.
English coverage is expanding. The pages below are available in English; the rest of the guide is in the [Chinese documentation](/guide/).
## Available in English
- [Getting started](/en/guide/getting-started) — install, pick a style mode and initialize the plugin.
- [API Reference](/en/guide/api-reference) — props, column fields, events, slots and the summary components.
|