Column Reordering

Let users drag column headers to rearrange the table layout.

Enable reordering

Set columnReordering so users can drag column headers to rearrange them.

React TSX
<SimpleTable columns={columns} rows={rows} height="400px" columnReordering={true} />

Handle order changes

Use onColumnOrderChange to update your columns state (and optionally persist the new order).

React TSX
const handleColumnOrderChange = (headers) => {
setColumns(headers);
};
<SimpleTable
columnReordering
columns={columns}
rows={rows}
onColumnOrderChange={handleColumnOrderChange}
/>

Lock a column

Set disableReorder on a column def to keep it fixed while others move.

TypeScript
{
accessor: "id",
label: "ID",
width: 60,
disableReorder: true,
}

Example

Drag column headers to reorder them.

Props

Column Reordering Configuration

PropertyRequiredDescriptionExample
columnReordering
boolean
Optional
Enables drag-and-drop reordering of column headers.
onColumnOrderChange
(newHeaders: ColumnDef[]) => void
Optional
Fires with the updated column defs after the user reorders columns.
ColumnDef.disableReorder
boolean
Optional
Prevents this column from being reordered.