# react-tbl

> A lightweight & easy to use react table implementation.

Latest version **0.8.0** (published 2020-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-tbl
pnpm add react-tbl
yarn add react-tbl
bun add react-tbl
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2020-11-08 |
| First published | 2020-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 47.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | uriportnoy |
| Keywords | react-tbl, react-table, table, tbl |

## Links

- npm: https://www.npmjs.com/package/react-tbl
- Repository: https://github.com/uriportnoy/react-tbl
- Homepage: https://github.com/uriportnoy/react-tbl#readme
- Issues: https://github.com/uriportnoy/react-tbl/issues
- npm.io page: https://npm.io/package/react-tbl

## Dependencies (1)

- [styled-components](https://npm.io/package/styled-components.md) ^5.1.0

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 0.8.0 (latest) — 2020-11-08
- 0.7.9 — 2020-11-08
- 0.7.8 — 2020-11-04
- 0.7.7 — 2020-11-04
- 0.7.6 — 2020-11-02
- 0.7.5 — 2020-11-02
- 0.7.4 — 2020-11-02
- 0.7.3 — 2020-09-04
- 0.7.2 — 2020-09-03
- 0.7.1 — 2020-09-03
- 0.7.0 — 2020-09-02
- 0.6.9 — 2020-09-02
- 0.6.8 — 2020-08-08
- 0.6.7 — 2020-08-08
- 0.6.6 — 2020-08-08
- … 53 more at https://npm.io/package/react-tbl/versions

## README

# React-TBL

A lightweight & easy to use react table implementation.

## Getting Started [Installation]

To install react-tbl use the following command

```
npm i react-tbl
```

## Package Demo

[![Sample project for using the package](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-tbl-586yc)

## Usage

To use react-tbl in your app:

```js
import ReactTBL from 'react-tbl';

const App = () => {
	const tblData = [
		{
			id: 1,
			name: 'moses',
			state: true,
		},
		{
			id: 2,
			name: 'hoyas',
			state: true,
		},
	];
	const tblColumns = [
		{
			header: 'User Id',
			colKey: 'id',
			size: 1,
		},
		{
			header: 'User Name',
			colKey: 'name',
			size: 4,
			copyCellDataOnClick: true,
			showToolTip: true,
		},
		{
			header: 'User State',
			colKey: 'state',
			size: 2,
			sortable: false,
			CustomCell: ({ dataRow, currentKey, currentValue }) => (
				<input
					className='customInputCell'
					value={currentValue.toString()}
					readOnly
				/>
			),
		},
	];
	return <ReactTBL data={tblData} columns={tblColumns} />;
};
```

## Props Example

```js
    <ReactTBL
        data = {currentData}
        columns = {columnsData}
        className = "custom_class_name"              // [optional]
        defaultPageSize = {10}                       // [optional] - default = 12
        copyCellDataOnClick = {true}                 // [optional]
        showPagination = {true}                      // default = true
        showToolTip = {true}                         // default = false
        sortable = {true}                            // default = true
        columnsResize = {true}                       // default = false
        isLoading = {true}                           // shows loader
        CustomLoader = {Loader}                      // custom loader component [optional]
        resize = {true}                              // default = false
        style = {{                                   // custom style [optional]
           maxWidth: '250px',
           minHeight: '400pt',
           maxHeight: '50px',
           minWidth: 'auto',
           rowBGColor: 'yellow',
           textColor: 'red',
           columnMinWidth: '100px',                     // = 100 px
           fontFamily: 'arial',

          header: {
            headerColor: '#fff',
            headerBGColor: '#333',
            fontSize: '11pt',
            borderColor: '#000',
            sortSign: '^',
          },

          body:{
            maxHeight: '150px',
            minHeight: '200pt',
            tooltipTextColor: '#555',
            tooltipBorderColor: 'yellow',
            tooltipBgColor: 'green'
            backgroundColor: 'yellow',
            borderColor: 'yellow',
            fontSize: '12pt',
          },

          pagination: {
            color: '#fff',
            borderColor: '#000',
            backgroundColor: '#333',
            btnsBGColor: '#000',
            prevButtonText: null,
            nextButtonText: 'Next >'
          },
        }}
    />
}
```

## Columns [Array of columns objects]

```js
[
    {
        header: 'User Id',          // header label [String]
        colKey: 'id',               // key accessor [String]
        size: 1,                    // column width [Number]
        showToolTip: true           // show tool tip for specific cell
        sortable: false,            // in order to cancel sort option for specific column
        copyCellDataOnClick: true,  // enable/disable 'copy cell's data' on specific column
        CustomCell: function({ dataRow, currentKey,currentValue,pageData,setPageData })
    }
]
```

## Data [Array of data]

```js
[
	{
		id: 1,
		name: 'Moses',
		state: true,
	},
	{
		id: 2,
		name: 'Hoyas',
		state: false,
	},
];
```

## Table props

|       General       | Default |
| :-----------------: | :-----: |
|        data         |         |
|       columns       |         |
|      className      |         |
|   defaultPageSize   |   12    |
|      sortable       |  true   |
| copyCellDataOnClick |  false  |
|   showPagination    |  true   |
|     showToolTip     |  false  | shows tool tip for each cell |
|        style        |         |
|      isLoading      |         | shows loader when is loading = true |
|    CustomLoader     |         | custom loader component |
|    columnsResize    |  false  |
|       resize        |  true   |

## Table style

|    General     |   Default    |
| :------------: | :----------: |
|   maxHeight    |    300px     |
|   minHeight    |    100px     |
|    maxWidth    |     40vw     |
|    minWidth    |     auto     |
|     border     |  1px solid   |
|   rowBGColor   | #f7f7f7/#eee |
|   textColor    |     #000     |
| columnMinWidth |    100px     |
|   overflowX    |     auto     |
|   overflowY    |     auto     |
|   fontFamily   |  monospace   |

## Header, Body, Pagination

|    Header     | Default |        Body        | Default |   Pagination    | Default  |
| :-----------: | :-----: | :----------------: | :-----: | :-------------: | :------: |
|  headerColor  |  #fff   |     maxHeight      |  200px  |      color      |   #fff   |
| headerBGColor |  #333   |     minHeight      |  auto   | backgroundColor |   #333   |
|  borderColor  |  #000   |    cellPadding     |   4pt   |   btnsBGColor   |   #333   |
|   fontSize    |  12pt   |  tooltipTextColor  |  #000   |    btnsColor    |   #fff   |
|   sortSign    |    ↑    | tooltipBorderColor |  #000   | prevButtonText  | Previous |
|               |         |   tooltipBgColor   | #f7f7f7 | nextButtonText  |   Next   |
|               |         |  backgroundColor   |  #333   |     border      |   none   |
|               |         |    borderColor     | #eaeaeb |                 |          |
|               |         |      fontSize      |  10pt   |                 |          |
|               |         |     rowHeight      |  30px   |                 |          |

## User table custom STYLE

```js
{
    minHeight:      '120px',
    maxWidth:       '450px',
    maxHeight:      '120px',
    minWidth:       '800px',
    rowBGColor:     '#000' ,
    textColor:      '#000' ,
    columnMinWidth: '100px',
    overflowX: 'auto',
    fontFamily: 'monospace',
    header: {
        headerColor: '#fff',
        headerBGColor: '#333',
        fontSize: '11pt',
        borderColor: '#333',
        sortSign: '^'
    },
    body:{
        maxHeight: 'auto',
        tooltipTextColor: '#555',
        tooltipBorderColor: 'yellow',
        tooltipBgColor: 'green'
    },
    pagination: {
        color: '#fff',
        backgroundColor: '#333',
        borderColor: '#000',
        btnsBGColor: '#000',
        btnsColor: '#fff',
        prevButtonText: null,
        nextButtonText: 'Next >'
    },
}
```

---
_Source: https://npm.io/package/react-tbl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
