1.2.3 • Published 11 months ago

react-table-column-resizer v1.2.3

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
11 months ago

React Table Column Resizer

A simple column resizer component for Html 5 Table

Inspired from React Column Resizer, Fixed width and drag problems

Place in between td tags to add resizing functionality and add "column_resize_table" to the table. Works with touch and mouse events.

Note: Don't add any min-width through css for table columns other than resize component

For react version 16 use version 1.0.2

Demo: https://codesandbox.io/s/react-table-column-resizer-3yuqv

Usage:

npm install react-table-column-resizer

Add column_resize_table class to the table

Add css

.column_resize_table th::before {content: ''; display: block; width: var(--column_resize_before_width);}

to css files

* Requires react as a peer dependency: npm install react

import React from "react";
import { render } from "react-dom";
import ColumnResizer from "react-table-column-resizer";

const App = () => (
  <div>
    <table class="column_resize_table">
      <tbody>
        <tr>
          <td>1</td>
          <ColumnResizer className="columnResizer" minWidth={0} />
          <td>2</td>
        </tr>

        <tr>
          <td>3</td>
          <td />
          <td>4</td>
        </tr>
      </tbody>
    </table>
  </div>
);

render(<App />, document.body);

Props

Prop NameTypeDefault ValueDescription
id (mandatory)numberUniq id for each column resize
disabledboolfalseSet to true if you want to disable resizing
minWidth (optional)numberundefinedThe minimum width for the columns (in pixels)
maxWidth (optional)numbernull, undefinedThe maximum width for the columns (in pixels)
defaultWidth (optional)numbernull, undefinedThe default width for the columns (in pixels)
resizeStart (optional)functionfunction(): voidTrigger when resize start
resizeEnd (optional)functionfunction(): numberTrigger when resize end and return the last dragged column width
classNamestring""Any custom classes. If set, default width and backgroundColor styles will not be applied

Limitations

  • You have to put filler <td/>'s in rows
  • The width in table column need to be in logic of table css, it must leave a column without max-width
1.2.0

11 months ago

1.1.1

11 months ago

1.0.2

11 months ago

1.1.0

11 months ago

1.1.9

11 months ago

1.1.8

11 months ago

1.0.9

11 months ago

1.1.7

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.1.5

11 months ago

1.0.6

11 months ago

1.2.3

11 months ago

1.1.4

11 months ago

1.0.5

11 months ago

1.2.2

11 months ago

1.1.3

11 months ago

1.0.4

11 months ago

1.2.1

11 months ago

1.1.2

11 months ago

1.0.3

11 months ago

1.0.1

3 years ago

1.0.0

3 years ago