Skip to content

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.

Edit in Playground

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:

ts
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.

OptionDescription
titleTooltip content; a sorter tooltip without it uses the text of the current sort action.
placementtop, bottom, left, right.
mouseEnterDelay / mouseLeaveDelayShow and hide delays, in seconds.
color / arrow / classBackground 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: true generates filter items from the enum, keeps the original value types and uses equality comparison by default.
  • filters: false turns off the enum filter entry; you can also pass an array of filter items explicitly.
  • onFilter: true uses equality comparison, onFilter: false skips local filtering, and a custom function takes precedence and applies the application's own rules.
  • manual.filter: true skips 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 ​

PropTypeDefaultDescription
columnEmptyTextVNodeChild | falsefalseReplaces null or undefined cell values; zero, false and empty strings are kept.
transformCellTextTransformCellText<TRecord>-Transforms cell text in one place; opt contains text, column, record and index.
headerEllipsisbooleanfalseAlso truncates the headers of columns that enable column.ellipsis to a single line with an ellipsis.
showSorterTooltipboolean | TableTooltipConfigtrue for antdv, false for element-plusTable-level sorter tooltip config; a column-level showSorterTooltip overrides it.

Column fields ​

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.
ellipsisboolean | { showTitle?: boolean }falseTruncates overflowing cell content with an ellipsis; with showTitle: false, the hover tooltip is not shown.
showSorterTooltipboolean | TableTooltipConfigInherits the table-level settingColumn-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.

FieldTypeDefaultDescription
textstring | ((context: CustomRenderContext<TRecord>) => string | Promise<string>)Cell textContent 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.

FieldTypeDefaultDescription
titleVNodeChild-Tooltip content.
placement'top' | 'bottom' | 'left' | 'right''top'Side on which the tooltip appears.
mouseEnterDelaynumber0.1Delay before showing after the pointer enters, in seconds.
mouseLeaveDelaynumber0.1Delay before hiding after the pointer leaves, in seconds.
colorstring-Tooltip background color.
arrowbooleantrueWhether to show the arrow.
classstring-Class of the tooltip content.

Slots ​

SlotPayload typeDescription
bodyCellTableBodyCellSlotProps<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 ​

SlotDescription
headerCellInnerFlex wrapper inside the header cell.
bodyCellEllipsisText truncation layer for the content of ellipsis columns.
headerHelpHeader help icon for a column tooltip.
cellContentWrapper around the content and copy button of copyable columns.
copyButtonCopy button of copyable columns.
cellStatusvalueEnum status marker, colored by data-status.
cellTagTag 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.

ts
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)]',
      },
    },
  },
})
ts
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.

VariablePurposeantdvelement-plus
--color-primaryTheme primary color, used for drag handle hover, button highlights, field states and more#1677ff#409eff
--vtg-cell-tag-radiusTag radius4px4px
--vtg-cell-tag-padding-inlineTag horizontal padding7px9px
--vtg-cell-tag-font-sizeTag font size12px12px
--vtg-cell-tag-line-heightTag line height20px22px
--vtg-cell-tag-bgTag background; mixed from the current status color by defaultcolor-mix(in srgb, currentcolor 8%, var(--vtg-table-bg))color-mix(in srgb, currentcolor 10%, var(--vtg-table-bg))
--vtg-cell-tag-borderTag border colorcolor-mix(in srgb, currentcolor 30%, transparent)color-mix(in srgb, currentcolor 30%, transparent)
--vtg-cell-successField success status color#52c41a#67c23a
--vtg-cell-warningField warning status color#faad14#e6a23c
--vtg-cell-errorField error status color; also used for query and editing validation text#ff4d4f#f56c6c

Type Declarations ​

View type declarations
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 type TransformCellText<TRecord extends object = Record<string, any>> = (opt: {
  text: unknown
  column: ColumnType<TRecord>
  record: TRecord
  index: number
}) => unknown