Skip to content
Template Empire
Browse components

Table Column Resize

Resize semantic data-table columns with pointer or keyboard controls.

ProjectOwnerStatus
Atlas redesignMira ChenIn review
Meridian launchAvery JonesOn track

Customise

Code

const columns = [
  { id: "project", label: "Project", width: 180 },
  { id: "owner", label: "Owner", width: 140 },
  { id: "status", label: "Status", width: 130 },
];
const rows = [
  { id: "atlas", cells: { project: "Atlas redesign", owner: "Mira Chen", status: "In review" } },
  { id: "meridian", cells: { project: "Meridian launch", owner: "Avery Jones", status: "On track" } },
];

<TableColumnResize
  label="Quarterly operations"
  columns={columns}
  rows={rows}
/>

Table Column Resize gives readers room to inspect wide or important fields without changing the table's records. Each column has a starting width and optional bounds; its separator responds to pointer dragging and arrow keys.

The component keeps the table semantic and wraps horizontal overflow in a labelled scroll region. Data, sorting and persistence remain owned by your application.

Install

Add the @te registry to your components.json once:

{
  "registries": {
    "@te": "https://templateempire.io/r/{name}.json"
  }
}

Then install the component:

npx shadcn@latest add @te/table-column-resize

Usage

import { TableColumnResize } from "@/components/table-column-resize";

const columns = [
  { id: "project", label: "Project", width: 180, minWidth: 120, maxWidth: 280 },
  { id: "owner", label: "Owner", width: 140 },
];
const rows = [
  { id: "atlas", cells: { project: "Atlas redesign", owner: "Mira Chen" } },
];

export function ProjectTable() {
  return <TableColumnResize label="Projects" columns={columns} rows={rows} />;
}

Props

PropTypeDefaultDescription
labelstringrequiredAccessible name for the table and its horizontal scroll region.
columnsResizableTableColumn[]requiredOrdered columns with stable IDs, labels, initial widths and optional bounds.
rowsResizableTableRow[]requiredOrdered rows with stable IDs and cell values keyed by column ID.
columnWidthsRecord<string, number>undefinedControlled pixel widths keyed by column ID.
defaultColumnWidthsRecord<string, number>undefinedInitial uncontrolled overrides.
onColumnWidthsChange(widths) => voidundefinedReceives the complete width map after pointer or keyboard resizing.
emptyMessagestringNo rows to display.Message shown when the rows array is empty.
classNamestringundefinedAdditional classes merged onto the outer section.

Customisation

Widths are measured in CSS pixels and constrained by each column's minWidth and maxWidth. Arrow keys adjust by 8px; Shift plus an arrow adjusts by 24px.

<TableColumnResize label="Projects" columns={columns} rows={rows} />

Frequently asked questions

Does resizing change my data?
No. The component only changes column widths. Cell content and row order remain caller-owned.
How does this work on a narrow screen?
The table scrolls horizontally inside its labelled region. The page layout stays within the viewport.

Related components

Explore data componentsBrowse table components for data-heavy React interfaces.Table components