Socket
Socket
Sign inDemoInstall

react-table-lib

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-table-lib

React responsive table library


Version published
Maintainers
1
Install size
238 kB
Created

Readme

Source

React Table

Installation

yarn add react-table-lib

Usage

import Table from 'react-table-lib'

  • Basic Table

    const data = [
      { name: "Earline Stokes", age: 30 },
      { name: "Amina Bergstrom", age: 25 },
      { name: "Kattie Hoppe", age: 20 }
    ]
    
    return (
      <Table data={data}>
    )
    
  • Column mapped

    const data = [
      { name: "Earline Stokes", age: 30 },
      { name: "Amina Bergstrom", age: 25 },
      { name: "Kattie Hoppe", age: 20 }
    ]
    
    const columns = {
      name: { label: "Full Name", sortable: true },
      age: { label: "Age", format: (data) => data + 'yrs' }
    }
    
    return (
      <Table data={data} columns={columns}>
    )
    
  • Selectable

    const data = [
      { name: "Earline Stokes", age: 30 },
      { name: "Amina Bergstrom", age: 25 },
      { name: "Kattie Hoppe", age: 20 }
    ]
    
    const columns = {
      name: { label: "Full Name", sortable: true },
      age: { label: "Age", format: (data) => data + 'yrs' }
    }
    
    const handleSelect = (data) => {
      // do something
      // data [{ name: "Earline Stokes", age: 30 }]
    }
    
    return (
      <Table data={data} columns={columns} selectable="multiple" onSelect={handleSelect}>
    )
    

Table Properties

Props/MethodsDefaultTypeRequiredDetails
data-arraytrueTable Records in array format with each entry holding key : value pair
columns{}objectfalseEach property for data's entry's header property
Ref: Columns
selectable-'single'
'multiple'
falseSelectable option to select table record based on type single or multiple
onSelect-functionfalseCallback to get selected records details.
callback data: record (or) array of records

Columns Properties

PropertytypeDetails
labelstringTable Header column name
sortablebooleanColumn sortable property
formatfunctionFormatting table record for the same column

Demo

Code Sandbox

Note: Please run yarn storybook to see demo. You can run this in your local too to check the same

FAQs

Last updated on 18 Jan 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc