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,
+ )}
+
+