Socket
Socket
Sign inDemoInstall

react-native-responsive-grid-component

Package Overview
Dependencies
514
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-responsive-grid-component

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


Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Install size
29.4 kB
Created
Weekly downloads
 

Readme

Source

React Native Responsive Grid

version npm npm npm npm

The best responsive grid component for react-native and react-native-web.

Installation

Using yarn:

yarn add react-native-responsive-grid-component

Using npm:

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

Usage

First of all, you need to wrap your root component with the GridProvider.

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.

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.

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
PropDescriptionTypeDefault
sizesThe sizes of the Col component for each screen size.SizesProps{ xs: 12, sm: 6, md: 4, lg: 3, xl: 2 }
breakpointsThe breakpoints for each screen size.SizesProps{ xs: 500, sm: 730, md: 960, lg: 1450 }
paddingThe padding between the elements in the grid.number16
showBreakpointsWhether to show or not the breakpoints (for development purpouses).booleanfalse
breakpointsColorThe color of the breakpoints.stringblack
Grid

Accepts any View prop and the following.

PropDescriptionTypeDefault
xsNumber of columns (between 0 and 12) that the each item should take in screens of size xs.numberThe one defined in the sizes prop of the GridProvider.
smNumber of columns (between 0 and 12) that the each item should take in screens of size sm.numberThe one defined in the sizes prop of the GridProvider.
mdNumber of columns (between 0 and 12) that the each item should take in screens of size md.numberThe one defined in the sizes prop of the GridProvider.
lgNumber of columns (between 0 and 12) that the each item should take in screens of size lg.numberThe one defined in the sizes prop of the GridProvider.
xlNumber of columns (between 0 and 12) that the each item should take in screens of size xl.numberThe one defined in the sizes prop of the GridProvider.
paddingThe padding between the elements in the grid.numberThe one defined in the padding prop of the GridProvider.
rowStyleStyle for the Row component inside the grid.StyleProp<ViewStyle>
colStyleStyle for the Col components inside the grid.StyleProp<ViewStyle>
Col

Accepts any View prop and the following.

PropDescriptionTypeDefault
xsNumber of columns (between 0 and 12) that the each item should take in screens of size xs.numberThe one defined in the sizes prop of the GridProvider.
smNumber of columns (between 0 and 12) that the each item should take in screens of size sm.numberThe one defined in the sizes prop of the GridProvider.
mdNumber of columns (between 0 and 12) that the each item should take in screens of size md.numberThe one defined in the sizes prop of the GridProvider.
lgNumber of columns (between 0 and 12) that the each item should take in screens of size lg.numberThe one defined in the sizes prop of the GridProvider.
xlNumber of columns (between 0 and 12) that the each item should take in screens of size xl.numberThe one defined in the sizes prop of the GridProvider.
Row

Accepts any View prop.

License

MIT

Keywords

FAQs

Last updated on 25 Aug 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc