# TableState

**Category:** Base Components/Collections/Table/TableState

## API

### Overview

`TableState` manages the state for a [`Table`](./?path=/story/base-components-collections-table--table) component. It wraps a `CollectionState` for data, a `ToolbarCollectionState` for the toolbar, tracks visible columns and sorting, and supports virtual scrolling and drag-and-drop. Created by [`useTableCollection`](./?path=/story/base-components-collections-table-usetablecollection--usetablecollection).

### Description

`TableState` is the return value of the [`useTableCollection()`](./?path=/story/base-components-collections-table-usetablecollection--usetablecollection) hook.

### Props

| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `collection` | `CollectionState<T, F>` | Yes | - | Underlying [CollectionState](./?path=/story/common-state--collectionstate) instance |
| `toolbar` | `ToolbarCollectionState<T, F>` | Yes | - | Underlying [ToolbarCollectionState](./?path=/story/common-state--toolbarcollectionstate) instance |
| `onAddItemActionComplete` | `(items: T[]) => void` | Yes | - | Reset active filters & sorting and adds new items to the collection. @param items - new items to add to the collection |
| `visibleColumns` | `{ id: string; }[]` | Yes | - | Visible columns as selected via [CustomColumns](./?path=/story/features-display--customcolumns) |
| `sort` | `(columnId: string, params: { forceDirection?: SortOrder \| undefined; }) => void` | Yes | - | Sorts the collection by a specified column and optional sort direction. |

