From 27e38f3413df6a13278d6cb0a7c2c4009565f797 Mon Sep 17 00:00:00 2001 From: govindarajug <99521156+govindarajug@users.noreply.github.com> Date: Mon, 20 Apr 2026 07:56:46 +0530 Subject: [PATCH] feat: add full-width column resizing example Adds a new React example demonstrating how to make a table fill its container width with the last column stretching to occupy remaining space. Columns remain individually resizable while maintaining the full-width behavior. Uses ResizeObserver for responsive container tracking and CSS variables for performant resize rendering. This addresses a common use case discussed in #4825, #4880, #5120, and #5870 where users need tables that fill their container width with proper resize behavior. --- .../column-resizing-full-width/.gitignore | 5 + .../column-resizing-full-width/README.md | 13 ++ .../column-resizing-full-width/index.html | 13 ++ .../column-resizing-full-width/package.json | 27 +++ .../column-resizing-full-width/src/index.css | 78 +++++++ .../column-resizing-full-width/src/main.tsx | 211 ++++++++++++++++++ .../src/makeData.ts | 37 +++ .../column-resizing-full-width/tsconfig.json | 24 ++ .../column-resizing-full-width/vite.config.js | 17 ++ 9 files changed, 425 insertions(+) create mode 100644 examples/react/column-resizing-full-width/.gitignore create mode 100644 examples/react/column-resizing-full-width/README.md create mode 100644 examples/react/column-resizing-full-width/index.html create mode 100644 examples/react/column-resizing-full-width/package.json create mode 100644 examples/react/column-resizing-full-width/src/index.css create mode 100644 examples/react/column-resizing-full-width/src/main.tsx create mode 100644 examples/react/column-resizing-full-width/src/makeData.ts create mode 100644 examples/react/column-resizing-full-width/tsconfig.json create mode 100644 examples/react/column-resizing-full-width/vite.config.js diff --git a/examples/react/column-resizing-full-width/.gitignore b/examples/react/column-resizing-full-width/.gitignore new file mode 100644 index 0000000000..d451ff16c1 --- /dev/null +++ b/examples/react/column-resizing-full-width/.gitignore @@ -0,0 +1,5 @@ +node_modules +.DS_Store +dist +dist-ssr +*.local diff --git a/examples/react/column-resizing-full-width/README.md b/examples/react/column-resizing-full-width/README.md new file mode 100644 index 0000000000..abea8cb79d --- /dev/null +++ b/examples/react/column-resizing-full-width/README.md @@ -0,0 +1,13 @@ +# Full-Width Column Resizing Example + +This example demonstrates how to make a TanStack Table fill its container width, with the last column automatically stretching to fill remaining space. Columns can still be individually resized while maintaining the full-width behavior. + +This pattern is useful when you want the table to always fill its container (like a spreadsheet) rather than having a fixed width based on column sizes. + +## Key Features + +- Table always fills container width +- Last column stretches to fill remaining space +- Individual columns remain resizable +- Responsive to container size changes via ResizeObserver +- Double-click a column border to reset that column's size diff --git a/examples/react/column-resizing-full-width/index.html b/examples/react/column-resizing-full-width/index.html new file mode 100644 index 0000000000..3fc40c9367 --- /dev/null +++ b/examples/react/column-resizing-full-width/index.html @@ -0,0 +1,13 @@ + + +
+ + ++ The table fills its container. The last column stretches to fill any + remaining space. Try resizing individual columns — the last column + adjusts automatically. Resize the browser window to see the table adapt. +
+ +
+ {JSON.stringify(
+ {
+ containerWidth,
+ totalColumnsWidth,
+ shouldExtendLastColumn,
+ columnSizing: table.state.columnSizing,
+ },
+ null,
+ 2,
+ )}
+
+