# react-dash-grid

> React table component

Latest version **1.0.3** (published 2019-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-dash-grid
pnpm add react-dash-grid
yarn add react-dash-grid
bun add react-dash-grid
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-03-30 |
| First published | 2019-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ritesh Shrivastav |
| Maintainers | codingdash |
| Keywords | react, react-dash-grid, components |

## Links

- npm: https://www.npmjs.com/package/react-dash-grid
- Repository: https://github.com/codingdash/react-dash-grid
- Homepage: https://github.com/codingdash/react-dash-grid#readme
- Issues: https://github.com/codingdash/react-dash-grid/issues
- npm.io page: https://npm.io/package/react-dash-grid

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2019-03-30
- 1.0.2 — 2019-03-30
- 1.0.1 — 2019-03-29
- 1.0.0 — 2019-03-29

## README

# ReactDashGrid

Exeprimental React library to use table.

### Installation

The easiest way to use react-dash-grid is to install it from npm.

```sh
npm install --save react-dash-grid
```

Then, you can import ReactDashGrid component in your app.

```javascript
import ReactDashGrid from 'react-dash-grid';
```

### How to use?

Below is an example to show how you can use ReactDashGrid.

```javascript
import React, { Component } from 'react';
import ReactDashGrid from 'react-dash-grid';
import Email from '../components/Email';
import Image from '../components/Image';

const columns = [
  // `key` holds unique identifier for column, when passing row this key
  // connects the row value with the column
  { key: 'id', name: 'ID' },
  // `isValid` value is validator, for this column value. Before rendering email
  // this will check if the value is valid or not. If not valid, it'll not show
  // the value
  { key: 'email', name: 'Email', isValid: Email.isValid },
  // `renderer` allows you to use your component to render complex values, here
  // `Image` component takes care of rendering the image
  { key: 'image', name: 'Profile Pic', renderer: (props) => (
    <Image {...props}/>
  )},
];

class App extends Component {
  render() {
    return (
      <div className="App">
        <ReactDashGrid
          columns={columns}
          rows={[
            { id: 1, email: 'me@example.com', image: {src: 'https://example.com/abc.jpg'}}
          ]}
        />
      </div>
    );
  }
}

export default App;
```

### Customizing styles

You can pass class names for each components with `classes` property or you can
use `styles` props to add custom styles. These two props accept an object as
value and you can set following keys:

- table - for root level element
- theadRow - for header row
- theadCell - for header cell
- row - for data row
- cell - for data cell

In case you want to set custom styles for cell, you can still do it using
`renderer` property of column.

Below is an exaple how you can pass classes. Let's assume you are using
[@material-ui/core](https://www.npmjs.com/package/@material-ui/core) to
create classes then:

```javascript
import React, { Component } from 'react';
import ReactDashGrid from 'react-dash-grid';
import Email from '../components/Email';
import Image from '../components/Image';
import { withStyles } from '@material-ui/core/styles';

const styles = theme => ({
  table: {
    width: '100%'
  },
  theadRow: {
    fontWeight: 'bold'
  }
});

const columns = [
  { key: 'id', name: 'ID' },
  { key: 'email', name: 'Email', isValid: Email.isValid },
  { key: 'image', name: 'Profile Pic', renderer: (props) => (
    <Image {...props}/>
  )},
];

class App extends Component {
  render() {
    const { classes } = this.props;
    return (
      <div className="App">
        <ReactDashGrid
          columns={columns}
          rows={[
            { id: 1, email: 'me@example.com', image: {src: 'https://example.com/abc.jpg'}}
          ]}
          classes={{
            table: classes.table,
            theadRow: classes.theadRow
          }}
        />
      </div>
    );
  }
}

export default withStyles(styles)(App);
```

If you want to pass CSS styles directly, you can do something like below:

```javascript
import React, { Component } from 'react';
import ReactDashGrid from 'react-dash-grid';
import Email from '../components/Email';
import Image from '../components/Image';

const columns = [
  { key: 'id', name: 'ID' },
  { key: 'email', name: 'Email', isValid: Email.isValid },
  { key: 'image', name: 'Profile Pic', renderer: (props) => (
    <Image {...props}/>
  )},
];

class App extends Component {
  render() {
    const { classes } = this.props;
    return (
      <div className="App">
        <ReactDashGrid
          columns={columns}
          rows={[
            { id: 1, email: 'me@example.com', image: {src: 'https://example.com/abc.jpg'}}
          ]}
          styles={{
            table: {
              width: '100%'
            },
            theadRow: {
              fontWeight: 'bold'
            }
          }}
        />
      </div>
    );
  }
}

export default App;
```

---
_Source: https://npm.io/package/react-dash-grid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
