Socket
Socket
Sign inDemoInstall

react-data-table-component

Package Overview
Dependencies
Maintainers
1
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-data-table-component

A simple to use declarative react based data table


Version published
Weekly downloads
46K
decreased by-60.86%
Maintainers
1
Weekly downloads
 
Created

What is react-data-table-component?

The react-data-table-component package is a highly customizable and easy-to-use data table component for React applications. It provides a range of features including sorting, pagination, selectable rows, expandable rows, and custom styling.

What are react-data-table-component's main functionalities?

Basic Table

This code demonstrates how to create a basic data table with sortable columns using react-data-table-component.

import DataTable from 'react-data-table-component';

const data = [{ id: 1, title: 'Conan the Barbarian', year: '1982' }, { id: 2, title: 'The Terminator', year: '1984' }];

const columns = [
  { name: 'Title', selector: row => row.title, sortable: true },
  { name: 'Year', selector: row => row.year, sortable: true }
];

<DataTable columns={columns} data={data} />;

Pagination

This code demonstrates how to enable pagination in the data table.

import DataTable from 'react-data-table-component';

const data = [...Array(100).keys()].map(i => ({ id: i, title: `Title ${i}`, year: 2000 + i }));

const columns = [
  { name: 'Title', selector: row => row.title, sortable: true },
  { name: 'Year', selector: row => row.year, sortable: true }
];

<DataTable columns={columns} data={data} pagination />;

Selectable Rows

This code demonstrates how to make rows selectable in the data table.

import DataTable from 'react-data-table-component';

const data = [{ id: 1, title: 'Conan the Barbarian', year: '1982' }, { id: 2, title: 'The Terminator', year: '1984' }];

const columns = [
  { name: 'Title', selector: row => row.title, sortable: true },
  { name: 'Year', selector: row => row.year, sortable: true }
];

<DataTable columns={columns} data={data} selectableRows />;

Expandable Rows

This code demonstrates how to add expandable rows to the data table.

import DataTable from 'react-data-table-component';

const data = [{ id: 1, title: 'Conan the Barbarian', year: '1982', description: 'A movie about a barbarian.' }, { id: 2, title: 'The Terminator', year: '1984', description: 'A movie about a terminator.' }];

const columns = [
  { name: 'Title', selector: row => row.title, sortable: true },
  { name: 'Year', selector: row => row.year, sortable: true }
];

const ExpandedComponent = ({ data }) => <pre>{JSON.stringify(data, null, 2)}</pre>;

<DataTable columns={columns} data={data} expandableRows expandableRowsComponent={ExpandedComponent} />;

Custom Styling

This code demonstrates how to apply custom styles to the data table.

import DataTable from 'react-data-table-component';

const data = [{ id: 1, title: 'Conan the Barbarian', year: '1982' }, { id: 2, title: 'The Terminator', year: '1984' }];

const columns = [
  { name: 'Title', selector: row => row.title, sortable: true },
  { name: 'Year', selector: row => row.year, sortable: true }
];

const customStyles = {
  rows: {
    style: {
      minHeight: '72px', // override the row height
    },
  },
  headCells: {
    style: {
      paddingLeft: '8px', // override the cell padding for head cells
      paddingRight: '8px',
    },
  },
  cells: {
    style: {
      paddingLeft: '8px', // override the cell padding for data cells
      paddingRight: '8px',
    },
  },
};

<DataTable columns={columns} data={data} customStyles={customStyles} />;

Other packages similar to react-data-table-component

Keywords

FAQs

Package last updated on 24 Aug 2023

Did you know?

Socket

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc