tuil
ReferenceComponentsTables

Table

Table component API, behavior, and executable example.

View rawEdit

Loading executable example…

API and events

Render typed rows and columns with terminal-width fitting, virtualization, sorting, selection, and cell activation.

export function Table<TData>({
  columns,
  rows,
  getRowKey,
  selectedRowKeys,
  defaultSelectedRowKeys = [],
  onActivate,
  onSelectionChange,
  height = 10,
  width = 80,
  focusMode = "row",
  frozenColumns = 0,
  staticLimit = 1_000,
  ...props
}: TableProps<TData>): ReactNode;

Props, functions, and events

MemberTypeRequiredDescriptionRelated types
columnsreadonly TableColumn<TData>[]YesThe columns member uses the readonly TableColumn<TData>[] contract.
rowsreadonly TData[]YesThe rows member uses the readonly TData[] contract.
getRowKey(row: TData, index: number) => stringYesThe getRowKey member uses the (row: TData, index: number) => string contract.
heightnumber | undefinedNoThe height member uses the number | undefined contract.
widthnumber | undefinedNoThe width member uses the number | undefined contract.
focusMode"row" | "cell" | undefinedNoThe focusMode member uses the "row" | "cell" | undefined contract.
frozenColumnsnumber | undefinedNoThe frozenColumns member uses the number | undefined contract.
selectedRowKeysreadonly string[] | undefinedNoThe selectedRowKeys member uses the readonly string[] | undefined contract.
defaultSelectedRowKeysreadonly string[] | undefinedNoThe defaultSelectedRowKeys member uses the readonly string[] | undefined contract.
onActivate((row: TData, column: TableColumn<TData>, rowIndex: number) => void | Promise<void>) | undefinedNoThe onActivate member uses the ((row: TData, column: TableColumn<TData>, rowIndex: number) => void | Promise<void>) | undefined contract.
onSelectionChange((selected: readonly string[]) => void | Promise<void>) | undefinedNoThe onSelectionChange member uses the ((selected: readonly string[]) => void | Promise<void>) | undefined contract.
staticLimitnumber | undefinedNoThe staticLimit member uses the number | undefined contract.
variantstring | undefinedNoThe variant member uses the string | undefined contract.
size"sm" | "md" | "lg" | undefinedNoThe size member uses the "sm" | "md" | "lg" | undefined contract.
unstyledboolean | undefinedNoThe unstyled member uses the boolean | undefined contract.
classNamestring | undefinedNoThe className member uses the string | undefined contract.
layoutPartial<Omit<LayoutNodeInput, "children" | "id" | "semantics">> | undefinedNoThe layout member uses the Partial<Omit<LayoutNodeInput, "children" | "id" | "semantics">> | undefined contract.
idstring | undefinedNoThe id member uses the string | undefined contract.
testIdstring | undefinedNoThe testId member uses the string | undefined contract.
roleSemanticRole | undefinedNoThe role member uses the SemanticRole | undefined contract.SemanticRole
labelstring | undefinedNoThe label member uses the string | undefined contract.
descriptionstring | undefinedNoThe description member uses the string | undefined contract.
disabledboolean | undefinedNoThe disabled member uses the boolean | undefined contract.
readOnlyboolean | undefinedNoThe readOnly member uses the boolean | undefined contract.
selectedboolean | undefinedNoThe selected member uses the boolean | undefined contract.
checkedboolean | undefinedNoThe checked member uses the boolean | undefined contract.
expandedboolean | undefinedNoThe expanded member uses the boolean | undefined contract.
valueTextstring | undefinedNoThe valueText member uses the string | undefined contract.
slotsPartial<SlotComponents<&#123; root: import("ink").BoxProps; header: import("ink").BoxProps; headerCell: import("ink").TextProps; body: import("ink").BoxProps; row: import("ink").BoxProps; cell: import("ink").TextProps; overflow: import("ink").TextProps; empty: import("ink").TextProps; &#125;>> | undefinedNoThe slots member uses the Partial<SlotComponents<&#123; root: import("ink").BoxProps; header: import("ink").BoxProps; headerCell: import("ink").TextProps; body: import("ink").BoxProps; row: import("ink").BoxProps; cell: import("ink").TextProps; overflow: import("ink").TextProps; empty: import("ink").TextProps; &#125;>> | undefined contract.BoxProps, SlotComponents, TextProps
slotPropsPartial<SlotProps<&#123; root: import("ink").BoxProps; header: import("ink").BoxProps; headerCell: import("ink").TextProps; body: import("ink").BoxProps; row: import("ink").BoxProps; cell: import("ink").TextProps; overflow: import("ink").TextProps; empty: import("ink").TextProps; &#125;, object>> | undefinedNoThe slotProps member uses the Partial<SlotProps<&#123; root: import("ink").BoxProps; header: import("ink").BoxProps; headerCell: import("ink").TextProps; body: import("ink").BoxProps; row: import("ink").BoxProps; cell: import("ink").TextProps; overflow: import("ink").TextProps; empty: import("ink").TextProps; &#125;, object>> | undefined contract.BoxProps, SlotProps, TextProps

onActivate, onSelectionChange, onToggleSelection, and onSortColumn expose table intent.

Callback props run after the documented input is accepted. Callbacks are not cancellable unless their return type or description states otherwise.

Interaction and capabilities

Arrow keys navigate cells or rows; Space toggles selection; Enter activates; configured keys sort columns.

The published manifest records keyboard, focus, pointer, theme, terminal, semantic, event, and dependency requirements.

Complete import

import { Table } from "@/components/tuil/data-display/complex-data";

On this page