Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-grid-layout

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-grid-layout

A draggable and resizable grid layout with responsive breakpoints, for React.

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
640K
increased by12.79%
Maintainers
1
Weekly downloads
 
Created

What is react-grid-layout?

react-grid-layout is a powerful library for creating dynamic and responsive grid layouts in React applications. It allows developers to create draggable, resizable, and responsive grid layouts with ease.

What are react-grid-layout's main functionalities?

Draggable Grid Items

This feature allows you to create grid items that can be dragged around within the grid. The layout array defines the position and size of each grid item.

import React from 'react';
import GridLayout from 'react-grid-layout';

const layout = [
  {i: 'a', x: 0, y: 0, w: 1, h: 2},
  {i: 'b', x: 1, y: 0, w: 3, h: 2},
  {i: 'c', x: 4, y: 0, w: 1, h: 2}
];

const MyFirstGrid = () => (
  <GridLayout className="layout" layout={layout} cols={12} rowHeight={30} width={1200}>
    <div key="a">A</div>
    <div key="b">B</div>
    <div key="c">C</div>
  </GridLayout>
);

export default MyFirstGrid;

Resizable Grid Items

This feature allows you to create grid items that can be resized by dragging their edges. The isResizable property in the layout array enables resizing for each grid item.

import React from 'react';
import GridLayout from 'react-grid-layout';

const layout = [
  {i: 'a', x: 0, y: 0, w: 1, h: 2, isResizable: true},
  {i: 'b', x: 1, y: 0, w: 3, h: 2, isResizable: true},
  {i: 'c', x: 4, y: 0, w: 1, h: 2, isResizable: true}
];

const MyFirstGrid = () => (
  <GridLayout className="layout" layout={layout} cols={12} rowHeight={30} width={1200}>
    <div key="a">A</div>
    <div key="b">B</div>
    <div key="c">C</div>
  </GridLayout>
);

export default MyFirstGrid;

Responsive Grid Layout

This feature allows you to create grid layouts that adapt to different screen sizes. The layouts object defines the layout for different breakpoints, making the grid responsive.

import React from 'react';
import { Responsive, WidthProvider } from 'react-grid-layout';

const ResponsiveGridLayout = WidthProvider(Responsive);

const layouts = {
  lg: [
    {i: 'a', x: 0, y: 0, w: 1, h: 2},
    {i: 'b', x: 1, y: 0, w: 3, h: 2},
    {i: 'c', x: 4, y: 0, w: 1, h: 2}
  ],
  md: [
    {i: 'a', x: 0, y: 0, w: 1, h: 2},
    {i: 'b', x: 1, y: 0, w: 2, h: 2},
    {i: 'c', x: 3, y: 0, w: 1, h: 2}
  ]
};

const MyResponsiveGrid = () => (
  <ResponsiveGridLayout className="layout" layouts={layouts} breakpoints={{lg: 1200, md: 996}} cols={{lg: 12, md: 10}}>
    <div key="a">A</div>
    <div key="b">B</div>
    <div key="c">C</div>
  </ResponsiveGridLayout>
);

export default MyResponsiveGrid;

Other packages similar to react-grid-layout

Keywords

FAQs

Package last updated on 09 Oct 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc