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 already use ant-design-vue or element-plus, finish the initialization here first, then read the migration and theming pages according to your project.
Requirements
- Node
^20.19.0or>=22.12.0 - pnpm
>=10.28.0 - Vue
^3.5.0 - Vite
^5or newer - For TypeScript projects, pinning to
5.9.3is recommended;6.0.3has also been verified
Install
TypeScript version limit
The vue-tsc toolchain verified by this project and the online Playground do not currently support TypeScript 7 or above. Use the verified TypeScript 5.9.3 or 6.0.3 first, and avoid installing typescript@latest directly.
The combination verified in a real project is Vue 3.5.26 and vue-tsc 3.2.2, together with the two TypeScript versions above. Type checking of plain .ts components passes under TS 7, but the existing vue-tsc cannot load its new compiler; other TS 7 Vue toolchains are not yet supported by this project. Earlier TypeScript versions also need separate verification.
The online Playground is pinned to TypeScript 5.9.3. It relies on a browser-loadable JS compiler and standard library declarations, so it cannot use the TS 7 native compiler today; this limit has nothing to do with the component's JavaScript runtime.
The component itself does not require the host project to install Tailwind CSS. First install the package:
pnpm add @vtable-guild/vtable-guildWhen a TypeScript project needs to install or adjust its type checking tools, use the verified combination:
pnpm add -D -E typescript@5.9.3 vue-tsc@3.2.2Configure the style entry
vtable-guild supports three style modes: prebuilt, tailwind3 and tailwind4.
prebuilt
When the project does not use Tailwind CSS, import the full prebuilt style entry directly.
For example, in src/main.css:
@import '@vtable-guild/vtable-guild/css/style';This entry already pre-generates the utilities the library needs internally. Using it requires no Tailwind CSS installation, no @tailwindcss/vite configuration and no scanning of this library's sources.
tailwind3
When the project uses Tailwind CSS 3, use the Tailwind 3 entry and add the library preset to the Tailwind config:
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],
}@import '@vtable-guild/vtable-guild/css/tailwind3';
@tailwind base;
@tailwind components;
@tailwind utilities;app.use(createVTableGuild({ cssMode: 'tailwind3' }))tailwind4
When the project uses Tailwind CSS 4, use the Tailwind 4 entry:
pnpm add -D tailwindcss @tailwindcss/viteimport { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [vue(), tailwindcss()],
})@import 'tailwindcss';
@import '@vtable-guild/vtable-guild/css/tailwind4';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
antdvpreset - the
element-pluspreset - theme tokens
- the base styles the components need at runtime
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 imports and styles 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:
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, just set themePreset to element-plus:
app.use(
createVTableGuild({
themePreset: 'element-plus',
}),
)Minimal example
<script setup lang="ts">
import { VTable, type TableColumnsType } from '@vtable-guild/vtable-guild'
interface UserRow {
key: string
name: string
age: number
status: string
}
const columns: TableColumnsType<UserRow> = [
{ title: 'Name', key: 'name', dataIndex: 'name', width: 180 },
{ title: 'Age', key: 'age', dataIndex: 'age', width: 96, align: 'right', sorter: true },
{
title: 'Status',
key: 'status',
dataIndex: 'status',
filters: [
{ text: 'Active', value: 'active' },
{ text: 'Paused', value: 'paused' },
],
onFilter: (value, record) => record.status === value,
},
]
const dataSource: UserRow[] = [
{ key: '1', name: 'Ada Lovelace', age: 28, status: 'active' },
{ key: '2', name: 'Grace Hopper', age: 32, status: 'paused' },
]
</script>
<template>
<VTable row-key="key" :columns="columns" :data-source="dataSource" bordered hoverable />
</template>Where to go next
- To estimate the cost of replacing your table, continue with Migrating from ant-design-vue
- To unify the visual system, continue with Three-layer theme overrides and Table CSS variables
- To confirm the differentiating capabilities, continue with the Feature comparison
Type Declarations
These are the plugin and column configuration declarations used on this page. The types they reference and the complete component props are in the type reference.
Type Declarations
export declare function createVTableGuild(options?: VTableGuildOptions): Pluginexport interface VTableGuildOptions {
themePreset?: ThemePresetName
cssMode?: VTableGuildCssMode
classPrefix?: string
theme?: VTableGuildThemeOverrides
locale?: LocaleName
locales?: LocaleRegistry
localeOverrides?: DeepPartial<VTableGuildLocale>
/** 安装时读取一次,不支持运行时切换。 */
compatClass?: boolean
}export type VTableGuildCssMode = 'prebuilt' | 'tailwind3' | 'tailwind4'export type ThemePresetName = 'antdv' | 'element-plus'export type TableColumnsType<TRecord extends object = Record<string, any>> = ColumnsType<TRecord>export type ColumnsType<TRecord extends object = Record<string, any>> = Array<
ColumnType<TRecord> | ColumnGroupType<TRecord> | ColumnSentinel
>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[]
}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>>
}