# react-native-responsive-grid-component

> A responsive grid component for react-native and react-native-web.

Latest version **1.0.0** (published 2022-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-responsive-grid-component
pnpm add react-native-responsive-grid-component
yarn add react-native-responsive-grid-component
bun add react-native-responsive-grid-component
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-08-25 |
| First published | 2022-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nicolas Lazzos |
| Maintainers | nicolaslazzos |
| Keywords | react-native, react-native-web, react-native-responsive-grid, react-native-responsive-grid-component, react-native-grid, grid |

## Links

- npm: https://www.npmjs.com/package/react-native-responsive-grid-component
- Repository: https://github.com/nicolaslazzos/react-native-responsive-grid
- Homepage: https://github.com/nicolaslazzos/react-native-responsive-grid#readme
- Issues: https://github.com/nicolaslazzos/react-native-responsive-grid/issues
- npm.io page: https://npm.io/package/react-native-responsive-grid-component

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-08-25

## README

## React Native Responsive Grid

[![version](https://img.shields.io/github/package-json/v/nicolaslazzos/react-native-responsive-grid/master?label=npm&style=flat-square)](https://www.npmjs.com/package/react-native-responsive-grid-component) 
[![npm](https://img.shields.io/npm/l/react-native-responsive-grid-component?style=flat-square)](https://www.npmjs.com/package/react-native-responsive-grid-component) 
[![npm](https://img.shields.io/badge/types-included-blue?style=flat-square)](https://www.npmjs.com/package/react-native-responsive-grid-component)
[![npm](https://img.shields.io/npm/dm/react-native-responsive-grid-component?style=flat-square&color=red)](https://www.npmjs.com/package/react-native-responsive-grid-component) 
[![npm](https://img.shields.io/github/stars/nicolaslazzos/react-native-responsive-grid?style=flat-square)](https://www.npmjs.com/package/react-native-responsive-grid-component) 

The best responsive grid component for react-native and react-native-web.

### Installation

Using yarn:

```bash
yarn add react-native-responsive-grid-component
```

Using npm:

```bash
npm install react-native-responsive-grid-component --save
```

### Example

Check the following example to see it in action and try changing the default props to see how it works.

[![npm](https://img.shields.io/static/v1?style=flat-square&label=Expo&message=Example&logo=expo)](https://snack.expo.io/@nicolaslazzos/react-native-responsive-grid-component-example)

### Usage

First of all, you need to wrap your root component with the `GridProvider`.

```javascript
import React from "react";
import { GridProvider } from "react-native-responsive-grid-component";

const App = () => {
  return (
    <GridProvider>
      {/* your content */}
    </GridProvider>
  );
};
```

Then you can use the `Grid` component in the rest of your app.

### How to use it

#### First way

You can use directly the `Grid` component as in the following example.

```javascript
import React from "react";
import { View, StyleSheet } from "react-native";
import { Grid } from "react-native-responsive-grid-component";

const App = () => {
  return (
    <Grid>
      {Array.from(Array(20).keys()).map((item, index) => {
        return (
          <View style={styles.card} />
        );
      })}
    </Grid>
  );
};

const styles = StyleSheet.create({
  card: {
    backgroundColor: "white",
    borderRadius: 8,
    minHeight: 200,
    overflow: "hidden",
    shadowColor: "#000",
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,
    elevation: 5,
  },
});

```

#### Second way

You can use directly the `Col` and `Row` components as in the following example.

```javascript
import React from "react";
import { View, StyleSheet } from "react-native";
import { Col, Row } from "react-native-responsive-grid-component";

const App = () => {
  return (
    <Row>
      {Array.from(Array(20).keys()).map((item, index) => {
        return (
          <Col>
            <View style={styles.card} />
          </Col>
        );
      })}
    </Row>
  );
};

const styles = StyleSheet.create({
  card: {
    backgroundColor: "white",
    borderRadius: 8,
    minHeight: 200,
    overflow: "hidden",
    shadowColor: "#000",
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,
    elevation: 5,
  },
});

```

### Properties

#### GridProvider

|      Prop       |                             Description                            |    Type      |                  Default                  |
| :-------------: | :----------------------------------------------------------------: | :----------: | :---------------------------------------: |
|      sizes      | The sizes of the `Col` component for each screen size.             | `SizesProps` | `{ xs: 12, sm: 6, md: 4, lg: 3, xl: 2 }`  |
|   breakpoints   | The breakpoints for each screen size.                              | `SizesProps` | `{ xs: 500, sm: 730, md: 960, lg: 1450 }` |
|     padding     | The padding between the elements in the grid.                      |   `number`   | `16`                                      |
| showBreakpoints | Whether to show or not the breakpoints (for development purpouses).|  `boolean`   | `false`                                   |
|breakpointsColor | The color of the breakpoints.                                      |   `string`   | `black`                                   |

#### Grid

Accepts any `View` prop and the following.

| Prop |         Description         | Type | Default |
| :--: | :-------------------------: | :--: | :-----: |
|    xs   | Number of columns (between 0 and 12) that the each item should take in screens of size `xs`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    sm   | Number of columns (between 0 and 12) that the each item should take in screens of size `sm`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    md   | Number of columns (between 0 and 12) that the each item should take in screens of size `md`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    lg   | Number of columns (between 0 and 12) that the each item should take in screens of size `lg`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    xl   | Number of columns (between 0 and 12) that the each item should take in screens of size `xl`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
| padding | The padding between the elements in the grid.                                                |       `number`       | The one defined in the `padding` prop of the `GridProvider`. |
|rowStyle | Style for the `Row` component inside the grid.                                               |`StyleProp<ViewStyle>`|
|colStyle | Style for the `Col` components inside the grid.                                              |`StyleProp<ViewStyle>`|

#### Col

Accepts any `View` prop and the following.

| Prop |         Description         | Type | Default |
| :--: | :-------------------------: | :--: | :-----: |
|    xs   | Number of columns (between 0 and 12) that the each item should take in screens of size `xs`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    sm   | Number of columns (between 0 and 12) that the each item should take in screens of size `sm`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    md   | Number of columns (between 0 and 12) that the each item should take in screens of size `md`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    lg   | Number of columns (between 0 and 12) that the each item should take in screens of size `lg`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |
|    xl   | Number of columns (between 0 and 12) that the each item should take in screens of size `xl`. |       `number`       | The one defined in the `sizes` prop of the `GridProvider`. |

#### Row

Accepts any `View` prop.

### License

[MIT](https://choosealicense.com/licenses/mit/)

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