# React-Grid-Layout [![travis build](https://travis-ci.org/STRML/react-grid-layout.svg?branch=master)](https://travis-ci.org/STRML/react-grid-layout) [![CDNJS](https://img.shields.io/cdnjs/v/react-grid-layout.svg)](https://cdnjs.com/libraries/react-grid-layout) [![npm package](https://img.shields.io/npm/v/react-grid-layout.svg?style=flat-square)](https://www.npmjs.org/package/react-grid-layout) [![npm downloads](https://img.shields.io/npm/dt/react-grid-layout.svg?maxAge=2592000)]() React-Grid-Layout is a grid layout system much like [Packery](http://packery.metafizzy.co/) or [Gridster](http://dsmorse.github.io/gridster.js/), for React. Unlike those systems, it is responsive and supports breakpoints. Breakpoint layouts can be provided by the user or autogenerated. RGL is React-only and does not require jQuery. ![BitMEX UI](http://i.imgur.com/oo1NT6c.gif) > GIF from production usage on [BitMEX.com](https://www.bitmex.com) [**[Demo](https://strml.github.io/react-grid-layout/examples/0-showcase.html) | [Changelog](/CHANGELOG.md) | [WebpackBin Editable demo](https://www.webpackbin.com/bins/-Kvr2qCxorvGMgVMxkmI)**] ## Table of Contents - [Demos](#demos) - [Features](#features) - [Installation](#installation) - [Usage](#usage) - [Responsive Usage](#responsive-usage) - [Providing Grid Width](#providing-grid-width) - [Grid Layout Props](#grid-layout-props) - [Responsive Grid Layout Props](#responsive-grid-layout-props) - [Grid Item Props](#grid-item-props) - [Contribute](#contribute) - [TODO List](#todo-list) ## Demos 1. [Showcase](https://strml.github.io/react-grid-layout/examples/0-showcase.html) 1. [Basic](https://strml.github.io/react-grid-layout/examples/1-basic.html) 1. [No Dragging/Resizing (Layout Only)](https://strml.github.io/react-grid-layout/examples/2-no-dragging.html) 1. [Messy Layout Autocorrect](https://strml.github.io/react-grid-layout/examples/3-messy.html) 1. [Layout Defined on Children](https://strml.github.io/react-grid-layout/examples/4-grid-property.html) 1. [Static Elements](https://strml.github.io/react-grid-layout/examples/5-static-elements.html) 1. [Adding/Removing Elements](https://strml.github.io/react-grid-layout/examples/6-dynamic-add-remove.html) 1. [Saving Layout to LocalStorage](https://strml.github.io/react-grid-layout/examples/7-localstorage.html) 1. [Saving a Responsive Layout to LocalStorage](https://strml.github.io/react-grid-layout/examples/8-localstorage-responsive.html) 1. [Minimum and Maximum Width/Height](https://strml.github.io/react-grid-layout/examples/9-min-max-wh.html) 1. [Dynamic Minimum and Maximum Width/Height](https://strml.github.io/react-grid-layout/examples/10-dynamic-min-max-wh.html) 1. [No Vertical Compacting (Free Movement)](https://strml.github.io/react-grid-layout/examples/11-no-vertical-compact.html) #### Projects Using React-Grid-Layout - [BitMEX](https://www.bitmex.com/) - [AWS CloudFront Dashboards](https://aws.amazon.com/blogs/aws/cloudwatch-dashboards-create-use-customized-metrics-views/) - [Grafana](https://grafana.com/) - [Metabase](http://www.metabase.com/) - [HubSpot](http://www.hubspot.com) - [ComNetViz](http://www.grotto-networking.com/ComNetViz/ComNetViz.html) - [Stoplight](https://app.stoplight.io) - [Reflect](https://reflect.io) - [ez-Dashing](https://github.com/ylacaute/ez-Dashing) - [Kibana](https://www.elastic.co/products/kibana) *Know of others? Create a PR to let me know!* ## Features * 100% React - no jQuery * Compatible with server-rendered apps * Draggable widgets * Resizable widgets * Static widgets * Configurable packing: horizontal, vertical, or off * Bounds checking for dragging and resizing * Widgets may be added or removed without rebuilding grid * Layout can be serialized and restored * Responsive breakpoints * Separate layouts per responsive breakpoint * Grid Items placed using CSS Transforms * Performance: [on](http://i.imgur.com/FTogpLp.jpg) / [off](http://i.imgur.com/gOveMm8.jpg), note paint (green) as % of time |Version | Compatibility | |----------------|------------------| | >= 0.11.3 | React 0.14 & v15 | | >= 0.10.0 | React 0.14 | | 0.8. - 0.9.2 | React 0.13 | | < 0.8 | React 0.12 | ## Installation Install the React-Grid-Layout [package](https://www.npmjs.org/package/react-grid-layout) package using [npm](https://www.npmjs.com/): ```bash npm install react-grid-layout ``` Include the following stylesheets in your application: ``` /node_modules/react-grid-layout/css/styles.css /node_modules/react-resizable/css/styles.css ``` ## Usage Use ReactGridLayout like any other component. The following example below will produce a grid with three items where: - users will not be able to drag or resize item `a` - item `b` will be restricted to a minimum width of 2 grid blocks and a maximum width of 4 grid blocks - users will be able to freely drag and resize item `c` ```javascript var ReactGridLayout = require('react-grid-layout'); var MyFirstGrid = React.createClass({ render: function() { // layout is an array of objects, see the demo for more complete usage var layout = [ {i: 'a', x: 0, y: 0, w: 1, h: 2, static: true}, {i: 'b', x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4}, {i: 'c', x: 4, y: 0, w: 1, h: 2} ]; return (
a
b
c
) } }); ``` You may also choose to set layout properties directly on the children: ```javascript var ReactGridLayout = require('react-grid-layout'); var MyFirstGrid = React.createClass({ render: function () { return (
a
b
c
) } }); ``` ### Usage without Browserify/Webpack A module usable in a `