Skip to content

Table Column Resize

The package now includes advanced column resize functionality that allows users to dynamically adjust table column widths with intuitive drag handles. This feature provides a seamless user experience for customizing table layouts.

  • Drag-to-Resize: Intuitive drag handles on column borders for easy resizing
  • Visual Feedback: Clear visual indicators during resize operations
  • Responsive Design: Maintains table responsiveness while allowing manual adjustments
  • Smooth Interactions: Smooth resize animations and real-time width updates
  • Cross-Browser Support: Works consistently across all modern browsers

The column resize system provides:

  1. Resize Handles: Interactive drag handles appear on column borders
  2. Real-time Updates: Column widths update instantly as you drag
  3. Visual Indicators: Clear feedback showing resize boundaries and constraints
  4. Smooth Animations: Fluid resize experience with smooth transitions
  5. Responsive Behavior: Maintains table layout integrity during resize operations
  6. Pagination Integration: Column widths are preserved across page breaks
  7. Percentage-based Sizing: Column widths are stored as percentages for consistent rendering

When you resize columns, the widths are automatically stored in the table’s columnSize attribute as comma-separated percentages:

// Example: 4 columns with different widths
"columnSize": "9.1,39.41,21.79,29.7"
// Column 1: 9.1% width
// Column 2: 39.41% width
// Column 3: 21.79% width
// Column 4: 29.7% width

This ensures that:

  • Column proportions are maintained across different screen sizes
  • Pagination preserves the exact column layout
  • Tables render consistently in print and digital formats

For advanced table functionality with pagination and column resize, use the PaginationTable extension:

import { useEditor } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import { PaginationTable } from 'tiptap-table-plus';
import { PaginationPlus } from 'tiptap-pagination-plus';
import { editorContent } from "./editorContent";
const { TableCellPlus, TableHeaderPlus, TableRowPlus, TablePlus } = PaginationTable;
const editor = useEditor({
extensions: [
StarterKit,
TablePlus.configure({
resizeHandleStyle: {
background: "gray",
},
}),
TableRowPlus,
TableCellPlus,
TableHeaderPlus,
PaginationPlus
],
content: editorContent,
});

When using pagination with column resize, the table content includes column sizing information:

The TablePlus extension supports various configuration options for column resize:

import { TablePlus } from 'tiptap-table-plus';
const editor = new Editor({
extensions: [
TablePlus.configure({
resizeHandleStyle: {
background: "gray", // Customize resize handle appearance
width: "4px",
opacity: 0.7,
},
}),
],
});

Customize the appearance of resize handles with the resizeHandleStyle option:

TablePlus.configure({
resizeHandleStyle: {
background: "#007bff", // Handle color
width: "4px", // Handle width
opacity: 0.8, // Handle opacity
borderRadius: "2px", // Handle border radius
hoverOpacity: 1.0, // Opacity on hover
},
})

Resize handles not appearing:

  • Ensure the table has proper CSS positioning (position: relative)
  • Check that the resizable option is enabled in configuration
  • Verify that table cells have the correct structure

Resize not working smoothly:

  • Check for CSS conflicts that might interfere with drag operations
  • Ensure proper event handling is in place
  • Verify browser compatibility
OptionTypeDefaultDescription
resizeHandleStyleobject{}Custom styling for resize handles
OptionTypeDefaultDescription
backgroundstring"#007bff"Background color of resize handles
widthstring"4px"Width of resize handles
opacitynumber0.8Opacity of resize handles
borderRadiusstring"2px"Border radius of resize handles
hoverOpacitynumber1.0Opacity when hovering over handles

Links: