0.1.3 • Published 3 years ago

react-any-table v0.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

React Any Table

Customizable Table component for React!

Takes in an array of objects (each object equal in length) and converts it to a table with the option of pagination.

Install

npm i -s react-any-table

Usage

Being customizable, the table will accept a number of props to change the look and function of your table

PropTypeDescriptionDefault
dataarray of objects(Required) Array of objects with each object being of equal length and depth. Every object must also have the same keys which will act as headers for the table.
headerColorstring (color)The color of the header for the tablewhite
headerBorderColorstring (color)border color of the header of the table#454545
headerBorderWidthnumberborder width of the table header1px
headerTextColorstring (color)text color for the header#454545
headerFontSizenumberfont size of the text in the header12px
rowColorstring (color)background color of the table's rowswhite
rowBorderColorstring (color)border color of the table's rows#D9D9D9
rowBorderWidthnumberborder width of the table's rows1px
rowTextColorstring (color)text color of the table's row items#454545
rowFontSizenumberfont size of each item in the table's rows12px
maxViewableWidthnumbermaximum number of pixels for the viewable width of the table (overflow will be scrollable)700px
maxViewableHeightnumbermaximum number of pixels for the viewable height of the table (overflow will be scrollable)530px
maxRowsnumbermaximum number of rows available in each page of the table (if default, then pagination will not be displayed and table's data will be scrollable)0
activePageColorstring (color)(for pagination) text color of the active page in the table#454545
inactivePageColorstring (color)(for pagination) text color of the inactive page in the table#D9D9D9
arrowLeftColorstring (color)(for pagination) color of the left arrow (if not disabled) in the pagination row#1890FF
arrowRightColorstring (color)(for pagination) color of the right arrow (if not disabled) in the pagination row#1890FF
Example
import React from 'react'
import Table from './Table'

const App = () => {
  return (
		<div style={{paddingTop: 20, paddingLeft: 20}}>
      <Table
       data={[
          {
            id: 1,
            item: 'eggs',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 2,
            item: 'milk',
            price: "$1.99",
            available: 'yes'
          },
          {
            id: 3,
            item: 'bread',
            price: "$3.99",
            available: 'no'
          },
          {
            id: 4,
            item: 'cheese',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 5,
            item: 'chicken',
            price: "$6.99",
            available: 'no'
          },
          {
            id: 6,
            item: 'eggs',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 7,
            item: 'milk',
            price: "$1.99",
            available: 'yes'
          },
          {
            id: 8,
            item: 'bread',
            price: "$3.99",
            available: 'no'
          },
          {
            id: 9,
            item: 'cheese',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 10,
            item: 'chicken',
            price: "$6.99",
            available: 'no'
          },
          {
            id: 11,
            item: 'eggs',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 12,
            item: 'milk',
            price: "$1.99",
            available: 'yes'
          },
          {
            id: 14,
            item: 'bread',
            price: "$3.99",
            available: 'no'
          },
          {
            id: 15,
            item: 'cheese',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 16,
            item: 'chicken',
            price: "$6.99",
            available: 'no'
          },
          {
            id: 17,
            item: 'eggs',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 18,
            item: 'milk',
            price: "$1.99",
            available: 'yes'
          },
          {
            id: 19,
            item: 'bread',
            price: "$3.99",
            available: 'no'
          },
          {
            id: 20,
            item: 'cheese',
            price: "$2.99",
            available: 'yes'
          },
          {
            id: 21,
            item: 'chicken',
            price: "$6.99",
            available: 'no'
          }          
        ]}
      />
		</div>  );
}

export default App;