fixed-data-table-2
A React table component designed to allow presenting millions of rows of data.
Top Related Projects
React components for efficiently rendering large lists and tabular data
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Feature-rich and customizable data grid React component
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Datatable for React based on material-ui's table with additional features
Datatables for React using Material-UI
Quick Overview
Fixed-Data-Table-2 is a React component for building and rendering data tables with large amounts of data. It's designed to handle performance-intensive scenarios with thousands of rows of data, offering features like fixed headers, columns, and row indices. This project is a fork of Facebook's original Fixed-Data-Table, maintained by the community.
Pros
- Excellent performance with large datasets
- Highly customizable with various styling options
- Supports fixed headers, columns, and row indices
- Compatible with React 16 and above
Cons
- Learning curve can be steep for complex implementations
- Documentation could be more comprehensive
- Less active development compared to some alternatives
- May be overkill for simpler table needs
Code Examples
- Basic table setup:
import React from 'react';
import {Table, Column, Cell} from 'fixed-data-table-2';
import 'fixed-data-table-2/dist/fixed-data-table.css';
const MyTable = () => (
<Table
rowHeight={50}
rowsCount={100}
width={1000}
height={500}
headerHeight={50}>
<Column
header={<Cell>Col 1</Cell>}
cell={<Cell>Column 1 static content</Cell>}
width={200}
/>
<Column
header={<Cell>Col 2</Cell>}
cell={<Cell>Column 2 static content</Cell>}
width={200}
/>
</Table>
);
- Dynamic cell content:
import React from 'react';
import {Table, Column, Cell} from 'fixed-data-table-2';
const data = [
{name: 'John', age: 30},
{name: 'Jane', age: 25},
// ... more data
];
const MyDynamicTable = () => (
<Table
rowHeight={50}
rowsCount={data.length}
width={600}
height={500}
headerHeight={50}>
<Column
header={<Cell>Name</Cell>}
cell={({rowIndex}) => (
<Cell>{data[rowIndex].name}</Cell>
)}
width={300}
/>
<Column
header={<Cell>Age</Cell>}
cell={({rowIndex}) => (
<Cell>{data[rowIndex].age}</Cell>
)}
width={300}
/>
</Table>
);
- Fixed columns:
import React from 'react';
import {Table, Column, Cell} from 'fixed-data-table-2';
const FixedColumnTable = () => (
<Table
rowHeight={50}
rowsCount={100}
width={1000}
height={500}
headerHeight={50}>
<Column
fixed={true}
header={<Cell>Fixed Col</Cell>}
cell={<Cell>Fixed Column Content</Cell>}
width={200}
/>
<Column
header={<Cell>Scrollable Col</Cell>}
cell={<Cell>Scrollable Column Content</Cell>}
width={800}
/>
</Table>
);
Getting Started
-
Install the package:
npm install fixed-data-table-2
-
Import the necessary components and styles:
import React from 'react'; import {Table, Column, Cell} from 'fixed-data-table-2'; import 'fixed-data-table-2/dist/fixed-data-table.css';
-
Create a basic table component:
const SimpleTable = () => ( <Table rowHeight={50} rowsCount={10} width={500} height={300} headerHeight={50}> <Column header={<Cell>Header</Cell>} cell={<Cell>Row Data</Cell>} width={500} /> </Table>
Competitor Comparisons
React components for efficiently rendering large lists and tabular data
Pros of react-virtualized
- More comprehensive set of components for virtualized rendering
- Better performance for large datasets and dynamic content
- More active development and community support
Cons of react-virtualized
- Steeper learning curve due to more complex API
- Less focus on fixed-layout tables compared to fixed-data-table-2
Code Comparison
react-virtualized:
import { List } from 'react-virtualized';
<List
width={300}
height={300}
rowCount={1000}
rowHeight={20}
rowRenderer={({ index, key, style }) => (
<div key={key} style={style}>
Row {index}
</div>
)}
/>
fixed-data-table-2:
import { Table, Column, Cell } from 'fixed-data-table-2';
<Table
rowHeight={50}
rowsCount={1000}
width={300}
height={300}
headerHeight={50}
>
<Column
header={<Cell>Col 1</Cell>}
cell={({rowIndex, ...props}) => (
<Cell {...props}>Data for row {rowIndex}</Cell>
)}
width={200}
/>
</Table>
Both libraries offer virtualized rendering for large datasets, but react-virtualized provides a more flexible API for various use cases beyond tables. fixed-data-table-2 focuses specifically on table layouts with fixed headers and columns. The choice between them depends on the specific requirements of your project and the complexity of the data presentation needed.
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Pros of TanStack Table
- More flexible and customizable, supporting various UI frameworks
- Better performance for large datasets with virtualization
- Active development and community support
Cons of TanStack Table
- Steeper learning curve due to its headless nature
- Requires more setup and configuration for basic use cases
Code Comparison
Fixed-Data-Table-2:
import { Table, Column, Cell } from 'fixed-data-table-2';
<Table
rowHeight={50}
rowsCount={rows.length}
width={1000}
height={500}
headerHeight={50}>
<Column
header={<Cell>Col 1</Cell>}
cell={({rowIndex, ...props}) => (
<Cell {...props}>
{rows[rowIndex][0]}
</Cell>
)}
width={200}
/>
</Table>
TanStack Table:
import { useTable } from '@tanstack/react-table';
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
columns,
data,
});
return (
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>{column.render('Header')}</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(row => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
))}
</tr>
);
})}
</tbody>
</table>
);
Feature-rich and customizable data grid React component
Pros of react-data-grid
- More active development and frequent updates
- Better TypeScript support and type definitions
- Easier to customize and extend with plugins
Cons of react-data-grid
- Less performant with large datasets
- Limited built-in features compared to fixed-data-table-2
- Steeper learning curve for advanced functionality
Code Comparison
react-data-grid:
import ReactDataGrid from 'react-data-grid';
const columns = [
{ key: 'id', name: 'ID' },
{ key: 'title', name: 'Title' }
];
const rows = [
{ id: 1, title: 'Example 1' },
{ id: 2, title: 'Example 2' }
];
function MyGrid() {
return <ReactDataGrid columns={columns} rows={rows} />;
}
fixed-data-table-2:
import { Table, Column, Cell } from 'fixed-data-table-2';
function MyTable() {
return (
<Table
rowHeight={50}
rowsCount={rows.length}
width={500}
height={300}
headerHeight={50}
>
<Column
header={<Cell>ID</Cell>}
cell={({rowIndex}) => <Cell>{rows[rowIndex].id}</Cell>}
width={100}
/>
<Column
header={<Cell>Title</Cell>}
cell={({rowIndex}) => <Cell>{rows[rowIndex].title}</Cell>}
width={400}
/>
</Table>
);
}
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Pros of TanStack Table
- More flexible and customizable, supporting various UI frameworks
- Better performance for large datasets with virtualization
- Active development and community support
Cons of TanStack Table
- Steeper learning curve due to its headless nature
- Requires more setup and configuration for basic use cases
Code Comparison
Fixed-Data-Table-2:
import { Table, Column, Cell } from 'fixed-data-table-2';
<Table
rowHeight={50}
rowsCount={rows.length}
width={1000}
height={500}
headerHeight={50}>
<Column
header={<Cell>Col 1</Cell>}
cell={({rowIndex, ...props}) => (
<Cell {...props}>
{rows[rowIndex][0]}
</Cell>
)}
width={200}
/>
</Table>
TanStack Table:
import { useTable } from '@tanstack/react-table';
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
columns,
data,
});
return (
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>{column.render('Header')}</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(row => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{row.cells.map(cell => (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
))}
</tr>
);
})}
</tbody>
</table>
);
Datatable for React based on material-ui's table with additional features
Pros of material-table
- More feature-rich with built-in sorting, filtering, and pagination
- Better integration with Material-UI components and styling
- Easier to set up and use for basic table needs
Cons of material-table
- Less performant for large datasets compared to fixed-data-table-2
- Limited customization options for complex table layouts
- Heavier bundle size due to additional features and dependencies
Code Comparison
material-table:
import MaterialTable from 'material-table'
<MaterialTable
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Age', field: 'age', type: 'numeric' }
]}
data={[{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }]}
/>
fixed-data-table-2:
import { Table, Column, Cell } from 'fixed-data-table-2'
<Table
rowHeight={50}
rowsCount={2}
width={500}
height={100}
headerHeight={50}>
<Column
header={<Cell>Name</Cell>}
cell={({rowIndex}) => (<Cell>{data[rowIndex].name}</Cell>)}
width={200}
/>
<Column
header={<Cell>Age</Cell>}
cell={({rowIndex}) => (<Cell>{data[rowIndex].age}</Cell>)}
width={200}
/>
</Table>
material-table offers a more concise and declarative API, while fixed-data-table-2 provides more granular control over table structure and rendering.
Datatables for React using Material-UI
Pros of mui-datatables
- Built specifically for Material-UI, offering seamless integration with MUI components
- More extensive built-in features like filtering, sorting, and responsive design
- Active development and frequent updates
Cons of mui-datatables
- Potentially slower performance for large datasets compared to fixed-data-table-2
- Less flexibility for custom styling outside of Material-UI design system
Code Comparison
mui-datatables:
import MUIDataTable from "mui-datatables";
const columns = ["Name", "Company", "City", "State"];
const data = [
["Joe James", "Test Corp", "Yonkers", "NY"],
["John Walsh", "Test Corp", "Hartford", "CT"],
];
const options = {
filterType: 'checkbox',
};
<MUIDataTable
title={"Employee List"}
data={data}
columns={columns}
options={options}
/>
fixed-data-table-2:
import {Table, Column, Cell} from 'fixed-data-table-2';
<Table
rowHeight={50}
rowsCount={data.length}
width={1000}
height={500}
headerHeight={50}>
<Column
header={<Cell>Name</Cell>}
cell={({rowIndex, ...props}) => (
<Cell {...props}>
{data[rowIndex].name}
</Cell>
)}
width={200}
/>
</Table>
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Fixed Data Table 2 for React · ·
Fixed-Data-Table-2 is a continuation of facebook/fixed-data-table. The original repo is no longer maintained and has many pull requests awaiting response.
FixedDataTable is a React component for building and presenting data in a flexible, powerful way. It supports standard table features, like headers, columns, rows, header groupings, and both fixed-position and scrolling columns.
The table was designed to handle thousands of rows of data without sacrificing performance. Scrolling smoothly is a first-class goal of FixedDataTable and it's architected in a way to allow for flexibility and extensibility.
Features of FixedDataTable:
- Fixed headers and footer
- Both fixed and scrollable columns
- Handling huge amounts of data
- Variable row heights (with adaptive scroll positions)
- Column resizing
- Performant scrolling
- Customizable styling
- Jumping to a row or column
- Controlled scroll API allows touch support
Things the FixedDataTable doesn't do:
- FixedDataTable does not provide a layout reflow mechanism or calculate content layout information such as width and height of the cell contents. The developer has to provide the layout information to the table instead.
- FixedDataTable does not handle sorting of data. Instead it allows the developer to supply data getters that can be sort-, filter-, or tail-loading-aware.
- FixedDataTable does not fetch the data (see above)
This version of FixedDataTable is maintained by Schrödinger, Inc. It is a forked version of Facebookâs FixedDataTable Repository available here available under the BSD License. Contributions and modifications to FixedDataTable are also subject to the BSD License (see here).
Getting started
Install fixed-data-table-2
using npm.
npm install fixed-data-table-2
Add the default stylesheet dist/fixed-data-table.css
using a link tag or import it with a CSS module.
Implementing a table involves three component types- <Table/>
,<Column/>
, and <Cell/>
.
<Table />
contains configuration information for the entire table, like dimensions and row count.
const rows =[0,1,2];
<Table
rowHeight={50}
rowsCount={100}
width={5000}
height={5050}
headerHeight={50}
...
</Table>
<Column />
defines the way data is displayed for one column in the table, including all cell behavior for that column. Rather than manipulating each cell directly, pass a cell component as a prop to the column, and the column will render a cell for each index in the data array.
<Column
header={<Cell>Col 1</Cell>}
cell={<Cell>Column 1</Cell>}
width={2000}
/>
The cell components in a column will receive the current array index of your data as a prop (this.props.rowIndex
). Use this to access the correct value for each cell.
const rows = [0,1,2];
<Column
header={<Cell>Column 1</Cell>}
cell={({rowIndex, ...props}) => (
<Cell {...props}>
{rows[rowIndex]}
</Cell>
)}
width={2000}
/>
If your data is an array of objects, define a columnKey
prop for each column and it too will be passed to all cells in that column.
const rows = [
{ someKey: "someValue" },
{ someKey: "anotherValue" },
{ someKey: "yetAnother" }
];
<Column
header={<Cell>Col 1</Cell>}
columnKey="someKey"
cell={({ rowIndex, columnKey, ...props }) =>
<Cell {...props}>
{rows[rowIndex][columnKey]}
</Cell>}
width={2000}
/>;
You may find it useful to define custom Cell components, which can also be passed to the Column:
const MyCustomCell = ({ isSpecial }) =>
<Cell>
{isSpecial ? "I'm Special" : "I'm Not Special"}
</Cell>;
<Column
header={<Cell>Col 3</Cell>}
cell={<MyCustomCell isSpecial/>}
width={2000}
/>
Code Sample
For more detailed examples, please see the examples section of the documentation. If you need help getting started with a React build system, we recommend create-react-app.
import React from 'react';
import ReactDOM from 'react-dom';
import {Table, Column, Cell} from 'fixed-data-table-2';
import 'fixed-data-table-2/dist/fixed-data-table.css';
// Table data as a list of array.
const rows = [
"first row",
"second row",
"third row"
// .... and more
];
// Custom cell implementation with special prop
const MyCustomCell = ({ mySpecialProp }) =>
<Cell>
{mySpecialProp === "column2" ? "I'm column 2" : "I'm not column 2"}
</Cell>;
// Render your table
ReactDOM.render(
<Table
rowHeight={50}
rowsCount={rows.length}
width={5000}
height={5000}
headerHeight={50}>
<Column
header={<Cell>Col 1</Cell>}
cell={<Cell>Column 1 static content</Cell>}
width={2000}
/>
<Column
header={<Cell>Col 2</Cell>}
cell={<MyCustomCell mySpecialProp="column2" />}
width={1000}
/>
<Column
header={<Cell>Col 3</Cell>}
cell={({rowIndex, ...props}) => (
<Cell {...props}>
Data for column 3: {rows[rowIndex]}
</Cell>
)}
width={2000}
/>
</Table>,
document.getElementById('example')
);
Browser Support
Chrome | Firefox | IE | Safari |
---|---|---|---|
Latest | Latest | 11+ | Unsupported* |
* Safari may function correct, but we are not actively testing with it
Contributions
Use GitHub issues for requests.
We actively welcome pull requests; learn how to contribute.
BY CONTRIBUTING TO FIXEDDATATABLE, YOU AGREE THAT YOUR CONTRIBUTIONS WILL BE LICENSED UNDER THE BSD LICENSE (see here). Furthermore, by contributing to FixedDataTable, you hereby grant to Schrödinger and any recipients of your contributions, including but not limited to users of this site, a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, use, make and distribute your contributions and any derivative works under all intellectual property rights including but not limited to copyright and patent. BY CONTRIBUTING TO FIXEDDATATABLE, YOU REPRESENT AND WARRANT THAT YOU ARE LEGALLY ENTITLED TO GRANT THE FOREGOING LICENSE.
Changelog
Changes are tracked as GitHub releases.
License
FixedDataTable
is BSD-licensed. We also provide an additional patent grant.
Top Related Projects
React components for efficiently rendering large lists and tabular data
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Feature-rich and customizable data grid React component
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Datatable for React based on material-ui's table with additional features
Datatables for React using Material-UI
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot