Table Docs
API Reference
Table API Reference
- Table
- TableOptions
- TableState
- TableMeta
- TableFeature
- TableFeatures
- StockFeatures
- CoreFeatures
- BaseAtoms
- Atoms
- ExternalAtoms
- constructTable
- tableOptions
- tableFeatures
- getInitialTableState
- OnChangeFn
- Updater
- DebugOptions
- TableController
- createTableHook
- LitTable
- AppLitTable
- CreateTableHookOptions
- subscribe
- SubscribeDirective
- SelectionSource
- FlexRender
- flexRender
Column API Reference
Row API Reference
Cell API Reference
Header API Reference
Features API Reference
- stockFeatures
- coreFeatures
- coreCellsFeature
- coreColumnsFeature
- coreHeadersFeature
- coreRowModelsFeature
- coreRowsFeature
- coreTablesFeature
- cellSpanningFeature
- columnFilteringFeature
- columnFacetingFeature
- rowAggregationFeature
- columnGroupingFeature
- columnOrderingFeature
- columnPinningFeature
- columnResizingFeature
- columnSizingFeature
- columnVisibilityFeature
- globalFilteringFeature
- rowExpandingFeature
- rowPaginationFeature
- rowPinningFeature
- rowSelectionFeature
- rowSortingFeature
- filterFns
- sortFns
- aggregationFns
- ColumnFilter
- ColumnPinningState
- ColumnSort
- PaginationState
- RowPinningState
- columnResizingState
- FilterFn
- FilterFns
- FilterMeta
- SortFn
- SortFns
- AggregationFns
- AggregationContext
- AggregationMergeContext
- AggregationFnDef
- AggregationFnDescriptor
- AggregationValueContext
- AggregationValueResult
- constructAggregationFn
- ColumnFiltersState
- ColumnOrderState
- ColumnPinningPosition
- ColumnResizeDirection
- ColumnResizeMode
- ColumnSizingState
- ColumnVisibilityState
- ExpandedState
- GroupingState
- RowPinningPosition
- RowSelectionState
- SortDirection
- SortingState
- AggregationFnOption
- AggregationResult
- FilterFnOption
- SortFnOption
- BuiltInAggregationFn
- BuiltInFilterFn
- BuiltInSortFn
Static Functions API Reference
AI/LLM: This documentation page is available in plain markdown format at/table/latest/docs/framework/lit/reference/functions/createTableHook.md
Table API Reference
createTableHook
ts
function createTableHook<TFeatures, TTableComponents, TCellComponents, THeaderComponents>(__namedParameters): CreateTableHookResult<TFeatures, TTableComponents, TCellComponents, THeaderComponents>;Defined in: packages/lit-table/src/createTableHook.ts:503
Creates a custom table hook with pre-bound components for composition.
This is the table equivalent of TanStack Form's createFormHook. It allows you to:
- Define features, row models, and default options once, shared across all tables
- Register reusable table, cell, and header components
- Access table/cell/header instances via @lit/context in those components
- Get a useAppTable hook that returns an extended table with App wrapper functions
- Get a createAppColumnHelper function pre-bound to your features
Type Parameters#
TFeatures#
TFeatures extends TableFeatures
TTableComponents#
TTableComponents extends Record<string, ComponentType<any>>
TCellComponents#
TCellComponents extends Record<string, ComponentType<any>>
THeaderComponents#
THeaderComponents extends Record<string, ComponentType<any>>
Parameters#
__namedParameters#
CreateTableHookOptions<TFeatures, TTableComponents, TCellComponents, THeaderComponents>
Returns#
CreateTableHookResult<TFeatures, TTableComponents, TCellComponents, THeaderComponents>
Example#
ts
// hooks/table.ts
export const {
createAppColumnHelper,
useAppTable,
useTableContext,
useCellContext,
useHeaderContext,
} = createTableHook({
features: tableFeatures({
rowPaginationFeature,
rowSortingFeature,
columnFilteringFeature,
paginatedRowModel: createPaginatedRowModel(),
sortedRowModel: createSortedRowModel(),
filteredRowModel: createFilteredRowModel(),
sortFns,
filterFns,
}),
tableComponents: { PaginationControls, RowCount },
cellComponents: { TextCell, NumberCell },
headerComponents: { SortIndicator, ColumnFilter },
})
// Create column helper with TFeatures already bound
const columnHelper = createAppColumnHelper<Person>()
// my-table.ts
@customElement('my-table')
class MyTable extends LitElement {
private appTable = useAppTable(this, {
columns,
data: this.data,
})
protected render() {
const table = this.appTable.table()
return html`
<table>
<thead>
${repeat(table.getHeaderGroups(), (hg) => hg.id, (hg) => html`
<tr>
${hg.headers.map((h) => table.AppHeader(h, (header) => html`
<th>${header.FlexRender()}</th>
`))}
</tr>
`)}
</thead>
<tbody>
${table.getRowModel().rows.map((row) => html`
<tr>
${row.getAllCells().map((c) => table.AppCell(c, (cell) => html`
<td>${cell.FlexRender()}</td>
`))}
</tr>
`)}
</tbody>
</table>
`
}
}