Cell display
Common display needs can be written directly in the column config: copyable copies content, tooltip provides a header description and valueEnum maps text and status. The table-level columnEmptyText sets the empty-value placeholder in one place. Custom customRender and bodyCell keep receiving their original context, so you can compose your application's own components.
Copying content
copyable: true uses the text after transformCellText and before enum mapping. Custom-rendered VNodes are not copied by reading their DOM text, and objects do not automatically turn into [object Object]. To copy a specific value, use copyable.text:
import type { TableColumnsType } from '@vtable-guild/vtable-guild'
interface Order {
key: number
number: string
}
const columns: TableColumnsType<Order> = [
{
key: 'number',
dataIndex: 'number',
title: 'Order number',
copyable: {
text: ({ record }) => record.number,
onCopy: (text, record) => console.log('Copied', text, record.key),
onError: (error) => console.error(error),
},
},
]text accepts a string, or a callback that returns a string / Promise; the callback argument is the same as the customRender context. Success and failure are reported through the component text and the onCopy / onError callbacks. The actual clipboard capability depends on the browser environment; the copy button stops the event from going on to trigger row selection, row expansion and similar actions.
Header descriptions and sorter tooltips
The column-level tooltip and the sorter tooltip are independent of each other: the former explains what the field means, the latter describes the sort action. tooltip accepts a string or a TableTooltipConfig; the table-level and column-level showSorterTooltip also support this config object.
| Option | Description |
|---|---|
title | Tooltip content; a sorter tooltip without it uses the text of the current sort action. |
placement | top, bottom, left, right. |
mouseEnterDelay / mouseLeaveDelay | Show and hide delays, in seconds. |
color / arrow / class | Background color, arrow and extra class. |
Column-level config takes precedence over table-level config; showSorterTooltip: false on a column turns off the sorter tooltip for that column. To adjust the look globally, use the existing Tooltip theme and tokens, so that the two table presets stay consistent.
Empty-value placeholder and render priority
columnEmptyText defaults to false, which keeps showing a blank. With column-empty-text="—", only null and undefined use the placeholder; the number 0, the boolean false and the empty string are still valid values, and the default rendering shows booleans as text.
The processing order is: read the value → transformCellText → enum mapping and default empty-value display → custom renderer or slot. customRender receives the text after the transform and before enum mapping, and takes precedence over bodyCell; content explicitly returned by custom rendering is not replaced by the shared placeholder or by enum styles.
Enum mapping and filtering
valueEnum accepts a plain object or a Map, and an enum item can be a string or { text, status }. The supported statuses are success, warning, error, processing and default, rendered through the theme slots and tokens of both presets.
Object enums are matched by string key; use a Map when you need to distinguish primitive types such as 0, '0' and false. Values without a match fall back to the default value display, and enums never modify the input records.
filters: truegenerates filter items from the enum, keeps the original value types and uses equality comparison by default.filters: falseturns off the enum filter entry; you can also pass an array of filter items explicitly.onFilter: trueuses equality comparison,onFilter: falseskips local filtering, and a custom function takes precedence and applies the application's own rules.manual.filter: trueskips all local filtering while keeping the filter state and events, which suits server-side handling.
Sorting still uses the raw record values, and a custom compare function can choose its own rules. Copying uses the transformed raw value by default; to copy the displayed enum text, specify copyable.text explicitly. For export, the application decides whether to use the raw value or the displayed text; the table does not replace export fields automatically.
The related types ColumnCopyable, ColumnValueEnum, ColumnValueEnumItem, ColumnValueStatus and TableTooltipConfig are all imported from @vtable-guild/vtable-guild.
API
TRecord is the application row type. See the API Reference for the table's full configuration.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
columnEmptyText | VNodeChild | false | false | Replaces null or undefined cell values; zero, false and empty strings are kept. |
transformCellText | TransformCellText<TRecord> | - | Transforms cell text in one place; opt contains text, column, record and index. |
headerEllipsis | boolean | false | Also truncates the headers of columns that enable column.ellipsis to a single line with an ellipsis. |
showSorterTooltip | boolean | TableTooltipConfig | true for antdv, false for element-plus | Table-level sorter tooltip config; a column-level showSorterTooltip overrides it. |
Column fields
| Field | Type | Default | Description |
|---|---|---|---|
copyable | boolean | object | - | Enables the copy button; for the object form, see options. |
tooltip | string | TableTooltipConfig | - | Header help text; for the object form, see options. |
valueEnum | ColumnValueEnum | - | Maps raw values to display text and status. Accepts an object or a Map. |
ellipsis | boolean | { showTitle?: boolean } | false | Truncates overflowing cell content with an ellipsis; with showTitle: false, the hover tooltip is not shown. |
showSorterTooltip | boolean | TableTooltipConfig | Inherits the table-level setting | Column-level sorter tooltip switch and config. |
customRender | (ctx: CustomRenderContext<TRecord>) => VNodeChild | RenderedCell | - | Custom body cell content. Returning a RenderedCell sets both the content and the cell attributes. |
copyable
The options when copyable is an object; passing true copies the cell text.
| Field | Type | Default | Description |
|---|---|---|---|
text | string | ((context: CustomRenderContext<TRecord>) => string | Promise<string>) | Cell text | Content to copy. Required when the cell value is not text, a number or a boolean. |
onCopy | (text: string, record: TRecord) => void | - | Called after a successful copy. |
onError | (error: unknown, record: TRecord) => void | - | Called after a failed copy. |
TableTooltipConfig
The options when the column tooltip or the table-level and column-level showSorterTooltip is an object.
| Field | Type | Default | Description |
|---|---|---|---|
title | VNodeChild | - | Tooltip content. |
placement | 'top' | 'bottom' | 'left' | 'right' | 'top' | Side on which the tooltip appears. |
mouseEnterDelay | number | 0.1 | Delay before showing after the pointer enters, in seconds. |
mouseLeaveDelay | number | 0.1 | Delay before hiding after the pointer leaves, in seconds. |
color | string | - | Tooltip background color. |
arrow | boolean | true | Whether to show the arrow. |
class | string | - | Class of the tooltip content. |
Slots
| Slot | Payload type | Description |
|---|---|---|
bodyCell | TableBodyCellSlotProps<TRecord> | Custom cell content. |
Theming
The classes of the copy button, header description and enum labels can be overridden with the per-instance ui or the global theme.table.slots. To adjust colors or sizes, use the CSS variables below. See Three-layer theme overrides for the override order.
ui slots
| Slot | Description |
|---|---|
headerCellInner | Flex wrapper inside the header cell. |
bodyCellEllipsis | Text truncation layer for the content of ellipsis columns. |
headerHelp | Header help icon for a column tooltip. |
cellContent | Wrapper around the content and copy button of copyable columns. |
copyButton | Copy button of copyable columns. |
cellStatus | valueEnum status marker, colored by data-status. |
cellTag | Tag appearance for valueType: 'tag' or a renderer with presentation: 'tag'. |
Preset defaults
Switch between the default classes of the two presets with the tabs below. For how to override utilities in the default precompiled mode, see prefix and override rules.
createVTableGuild({
theme: {
table: {
slots: {
headerCellInner: "flex min-w-0 items-center [&[data-align=center]]:before:content-[''] [&[data-align=center]]:before:shrink-0 [&[data-align=center]]:before:w-[var(--vtg-header-title-spacer,0px)]",
bodyCellEllipsis: 'block flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap has-[[data-vtg-edit-layout=stable]]:overflow-visible',
headerHelp: 'inline-flex shrink-0 items-center ml-1 text-[color:var(--color-muted)] cursor-help',
cellContent: 'inline-flex max-w-full items-center gap-1 align-top [&>div]:min-w-0 has-[[data-vtg-edit-layout=stable]]:flex has-[[data-vtg-edit-layout=stable]]:w-full',
copyButton: 'inline-flex shrink-0 items-center justify-center border-0 bg-transparent p-1 text-[color:var(--color-primary)] cursor-pointer disabled:opacity-50',
cellStatus: "inline-flex items-center gap-1 before:content-[''] before:size-1.5 before:rounded-full before:bg-[color:var(--color-muted)] [&[data-status=success]]:before:bg-[color:var(--vtg-cell-success)] [&[data-status=warning]]:before:bg-[color:var(--vtg-cell-warning)] [&[data-status=error]]:before:bg-[color:var(--vtg-cell-error)] [&[data-status=processing]]:before:bg-[color:var(--color-primary)]",
cellTag: 'inline-flex items-center whitespace-nowrap border border-[color:var(--vtg-cell-tag-border)] rounded-[var(--vtg-cell-tag-radius)] px-[var(--vtg-cell-tag-padding-inline)] text-[length:var(--vtg-cell-tag-font-size)] leading-[var(--vtg-cell-tag-line-height)] bg-[color:var(--vtg-cell-tag-bg)] text-[color:var(--color-muted)] [&[data-status=success]]:text-[color:var(--vtg-cell-success)] [&[data-status=warning]]:text-[color:var(--vtg-cell-warning)] [&[data-status=error]]:text-[color:var(--vtg-cell-error)] [&[data-status=processing]]:text-[color:var(--color-primary)]',
},
},
},
})createVTableGuild({
themePreset: 'element-plus',
theme: {
table: {
slots: {
headerCellInner: 'flex min-w-0 items-center [&[data-align=center]]:justify-center [&[data-align=right]]:justify-end',
bodyCellEllipsis: 'block flex-1 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap has-[[data-vtg-edit-layout=stable]]:overflow-visible',
headerHelp: 'inline-flex shrink-0 items-center ml-1 text-[color:var(--color-muted)] cursor-help',
cellContent: 'inline-flex max-w-full items-center gap-1 align-top [&>div]:min-w-0 has-[[data-vtg-edit-layout=stable]]:flex has-[[data-vtg-edit-layout=stable]]:w-full',
copyButton: 'inline-flex shrink-0 items-center justify-center border-0 bg-transparent p-1 text-[color:var(--color-primary)] cursor-pointer disabled:opacity-50',
cellStatus: "inline-flex items-center gap-1 before:content-[''] before:size-1.5 before:rounded-full before:bg-[color:var(--color-muted)] [&[data-status=success]]:before:bg-[color:var(--vtg-cell-success)] [&[data-status=warning]]:before:bg-[color:var(--vtg-cell-warning)] [&[data-status=error]]:before:bg-[color:var(--vtg-cell-error)] [&[data-status=processing]]:before:bg-[color:var(--color-primary)]",
cellTag: 'inline-flex items-center whitespace-nowrap border border-[color:var(--vtg-cell-tag-border)] rounded-[var(--vtg-cell-tag-radius)] px-[var(--vtg-cell-tag-padding-inline)] text-[length:var(--vtg-cell-tag-font-size)] leading-[var(--vtg-cell-tag-line-height)] bg-[color:var(--vtg-cell-tag-bg)] text-[color:var(--color-muted)] [&[data-status=success]]:text-[color:var(--vtg-cell-success)] [&[data-status=warning]]:text-[color:var(--vtg-cell-warning)] [&[data-status=error]]:text-[color:var(--vtg-cell-error)] [&[data-status=processing]]:text-[color:var(--color-primary)]',
},
},
},
})CSS variables
The table lists the defaults in light mode. Dark mode can be overridden separately through .dark.
| Variable | Purpose | antdv | element-plus |
|---|---|---|---|
--color-primary | Theme primary color, used for drag handle hover, button highlights, field states and more | #1677ff | #409eff |
--vtg-cell-tag-radius | Tag radius | 4px | 4px |
--vtg-cell-tag-padding-inline | Tag horizontal padding | 7px | 9px |
--vtg-cell-tag-font-size | Tag font size | 12px | 12px |
--vtg-cell-tag-line-height | Tag line height | 20px | 22px |
--vtg-cell-tag-bg | Tag background; mixed from the current status color by default | color-mix(in srgb, currentcolor 8%, var(--vtg-table-bg)) | color-mix(in srgb, currentcolor 10%, var(--vtg-table-bg)) |
--vtg-cell-tag-border | Tag border color | color-mix(in srgb, currentcolor 30%, transparent) | color-mix(in srgb, currentcolor 30%, transparent) |
--vtg-cell-success | Field success status color | #52c41a | #67c23a |
--vtg-cell-warning | Field warning status color | #faad14 | #e6a23c |
--vtg-cell-error | Field error status color; also used for query and editing validation text | #ff4d4f | #f56c6c |
Type Declarations
View type declarations
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 type TransformCellText<TRecord extends object = Record<string, any>> = (opt: {
text: unknown
column: ColumnType<TRecord>
record: TRecord
index: number
}) => unknown