Tool for debugging grid-based layouts

Usage no npm install needed!

<script type="module">
  import reactGridDebugger from '';



Visual Tool for debugging grid-based layouts

Grid Debugger Demo

NPM JavaScript Style Guide

Table of Contents


A layout based on a grid system can be something hard to visually debug: proportions, alignments and gutters may vary from project to project and making sure that each layout is well implemented takes both developer and designer time.

This is a visual tool based on a React component that adds a grid overlay on top of our current page, making it easier to see if the number of columns, spacings, etc are up to spec.


npm install --save react-grid-debugger
yarn add grid-debuger

Please check Should this be a dependency or a devDependency? to understand if you need it as a dev dependency or not


react-grid-debugger is a react component, so you can use it like you'd use any other component.

It accepts a theme prop so if your project uses styled-components/emotion and you have defined the breakpoints for your theme, you can pass it into the debugger.

import React, { Component } from 'react'

import GridDebugger from 'react-grid-debugger'

export default class App extends Component {
  render () {
    return (
          numCols={[1, 4, 12]}
          gutter={{ 320: '2rem', 680: '40px', 800: '50px'}}

Toggling the debugger

Pressing keys Ctrl and g simultaneously toggles the debugger visibility.

More configuration examples:

<GridDebugger numCols={12} gutter="40px" />
<GridDebugger numCols={12} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />
<GridDebugger numCols={12} gutter={['2rem', '40px', '50px', '1000px']} />
<GridDebugger numCols={[1, 4, 7]} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />
<GridDebugger maxWidth={'400px'} numCols={[1, 4, 12]} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />
<GridDebugger maxWidth={['280px', '600px', '1000px']} numCols={[1, 4, 12]} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />


Note that most of the props accept:

  • string or number: for indicating a single value for that prop.
  • array: an array (of numbers or strings) that should be used as values, ordered by breakpoints. This means that the first element of the array will be used for the first breakpoint, the second one for the second breakpoint, and so on. If no theme is provided to the debugger, the default breakpoints are used. If the number of values provided is bigger than the number of breakpoints, the remaining ones are discarded.
  • object: an object where each key represents a screen width and its property represents the value that should be used for that breakpoint.
Prop Type Required Description
show bool No wether the debugger should be initially visible (it can be toggled with ctrl + g)
theme No object represents the app theme, normally provided by a ThemeProvider, if you use styled-components/emotion
maxWidth string / array / object No grid maximum width
numCols number / array / object Yes number of columns
gutter string / array / object Yes gutter size

Should this be a dependency or a devDependency?

It's really up to you. You might want to just have it available locally and not worry abound bundling it, or you may want it to be available on a specific environment. If you do make it available in a prod build, make sure to use a separate chunk for it and only request it if really needed.