Skip to content

Repository files navigation

material-table

material-table

A simple and powerful Datatable for React based on Material-UI Table with some additional features.

Build StatusFinancial Contributors on Open Collectivenpm packageNPM DownloadsAverage time to resolve an issueFollow on TwitterGitter chat

Key features

Demo and documentation

You can access all code examples and documentation on our site material-table.com.

Support material-table

To support material-table visit SUPPORT page.

Issue Prioritizing

Issues would be prioritized according reactions count. is:issue is:open sort:reactions-+1-desc filter would be use.

List issues according to reaction score

Prerequisites

The minimum React version material-table supports is ^16.8.5 since material-table v1.36.1. This is due to utilising react-beautiful-dnd for drag & drop functionality which uses hooks.

If you use an older version of react we suggest to upgrade your dependencies or use material-table 1.36.0.

Installation

1.Install package

To install material-table with npm:

npm install material-table --save
npm install @material-ui/core --save

To install material-table with yarn:

yarn add material-table
yarn add @material-ui/core

2.Add material icons

There are two ways to use icons in material-table either import the material icons font via html OR import material icons and use the material-table icons prop.

HTML
<linkrel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>

OR

Import Material icons

Icons can be imported to be used in material-table offering more flexibility for customising the look and feel of material table over using a font library.

To install @material-ui/icons with npm:

npm install @material-ui/icons --save

To install @material-ui/icons with yarn:

yarn add @material-ui/icons

If your environment doesn't support tree-shaking, the recommended way to import the icons is the following:

importAddBoxfrom"@material-ui/icons/AddBox";importArrowDownwardfrom"@material-ui/icons/ArrowDownward";

If your environment support tree-shaking you can also import the icons this way:

import{AddBox,ArrowDownward}from"@material-ui/icons";

Note: Importing named exports in this way will result in the code for every icon being included in your project, so is not recommended unless you configure tree-shaking. It may also impact Hot Module Reload performance. Source: @material-ui/icons

Example

import{forwardRef}from'react';importAddBoxfrom'@material-ui/icons/AddBox';importArrowDownwardfrom'@material-ui/icons/ArrowDownward';importCheckfrom'@material-ui/icons/Check';importChevronLeftfrom'@material-ui/icons/ChevronLeft';importChevronRightfrom'@material-ui/icons/ChevronRight';importClearfrom'@material-ui/icons/Clear';importDeleteOutlinefrom'@material-ui/icons/DeleteOutline';importEditfrom'@material-ui/icons/Edit';importFilterListfrom'@material-ui/icons/FilterList';importFirstPagefrom'@material-ui/icons/FirstPage';importLastPagefrom'@material-ui/icons/LastPage';importRemovefrom'@material-ui/icons/Remove';importSaveAltfrom'@material-ui/icons/SaveAlt';importSearchfrom'@material-ui/icons/Search';importViewColumnfrom'@material-ui/icons/ViewColumn';consttableIcons={Add: forwardRef((props,ref)=><AddBox{...props}ref={ref}/>),Check: forwardRef((props,ref)=><Check{...props}ref={ref}/>),Clear: forwardRef((props,ref)=><Clear{...props}ref={ref}/>),Delete: forwardRef((props,ref)=><DeleteOutline{...props}ref={ref}/>),DetailPanel: forwardRef((props,ref)=><ChevronRight{...props}ref={ref}/>),Edit: forwardRef((props,ref)=><Edit{...props}ref={ref}/>),Export: forwardRef((props,ref)=><SaveAlt{...props}ref={ref}/>),Filter: forwardRef((props,ref)=><FilterList{...props}ref={ref}/>),FirstPage: forwardRef((props,ref)=><FirstPage{...props}ref={ref}/>),LastPage: forwardRef((props,ref)=><LastPage{...props}ref={ref}/>),NextPage: forwardRef((props,ref)=><ChevronRight{...props}ref={ref}/>),PreviousPage: forwardRef((props,ref)=><ChevronLeft{...props}ref={ref}/>),ResetSearch: forwardRef((props,ref)=><Clear{...props}ref={ref}/>),Search: forwardRef((props,ref)=><Search{...props}ref={ref}/>),SortArrow: forwardRef((props,ref)=><ArrowDownward{...props}ref={ref}/>),ThirdStateCheck: forwardRef((props,ref)=><Remove{...props}ref={ref}/>),ViewColumn: forwardRef((props,ref)=><ViewColumn{...props}ref={ref}/>)};<MaterialTableicons={tableIcons}.../>

Usage

Here is a basic example of using material-table within a react application.

importReact,{Component}from"react";importReactDOMfrom"react-dom";importMaterialTablefrom"material-table";classAppextendsComponent{render(){return(<divstyle={{maxWidth: "100%"}}><MaterialTablecolumns={[{title: "Adı",field: "name"},{title: "Soyadı",field: "surname"},{title: "Doğum Yılı",field: "birthYear",type: "numeric"},{title: "Doğum Yeri",field: "birthCity",lookup: {34: "İstanbul",63: "Şanlıurfa"}}]}data={[{name: "Mehmet",surname: "Baran",birthYear: 1987,birthCity: 63}]}title="Demo Title"/></div>);}}ReactDOM.render(<App/>,document.getElementById("react-div"));

Contributing

We'd love to have your helping hand on material-table! See CONTRIBUTING.md for more information on what we're looking for and how to get started.

If you have any sort of doubt, idea or just want to talk about the project, feel free to join our chat on Gitter :)

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

This project is licensed under the terms of the MIT license.

About

Datatable for React based on material-ui's table with additional features

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages