Reactstrap Grid

Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, five default responsive tiers, Sass variables and mixins, and dozens of predefined classes, properties and components.


How it works

Reactstrap and Bootstrap’s grid system uses a series of containers (Container), rows (Row), and columns (Col) to layout and align content. It’s built with flexbox and is fully responsive. Below is an example and an in-depth look at how the grid comes together.

New to or unfamiliar with flexbox? Read this CSS Tricks flexbox guide for background, terminology, guidelines, and code snippets.

One of three columns
One of three columns
One of three columns
import React from "react";

import { Container, Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row>
          <Col sm className="py-2 border rounded">
            <span>One of three columns</span>
          </Col>
          <Col sm className="py-2 border rounded">
            <span>One of three columns</span>
          </Col>
          <Col sm className="py-2 border rounded">
            <span>One of three columns</span>
          </Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

The above example creates three equal-width columns on small, medium, large, and extra large devices using our predefined grid classes. Those columns are centered in the page with the parent Container.

Grid options

While Bootstrap uses ems or rems for defining most sizes, pxs are used for grid breakpoints and container widths. This is because the viewport width is in pixels and does not change with the font size.

See how aspects of the Bootstrap grid system work across multiple devices with a handy table.

Extra small
<576px
Small
≥576px
Medium
≥768px
Large
≥992px
Extra large
≥1200px
Max container width None (auto) 540px 720px 960px 1140px
Class prefix xs prop sm prop md prop lg prop xl prop
# of columns 12
Gutter width 30px (15px on each side of a column)
Nestable Yes
Column ordering Yes

Auto-layout columns

Utilize breakpoint-specific column classes for easy column sizing without an explicit breakpoint prop like sm="6".

Equal-width

For example, here are two grid layouts that apply to every device and viewport, from xs to xl. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.

1 of 2
2 of 2
1 of 3
2 of 3
3 of 3
import React from "react";

import { Container, Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row>
          <Col className="py-2 border rounded">
            <span>1 of 2</span>
          </Col>
          <Col className="py-2 border rounded">
            <span>2 of 2</span>
          </Col>
        </Row>
        <Row>
          <Col className="py-2 border rounded">
            <span>1 of 3</span>
          </Col>
          <Col className="py-2 border rounded">
            <span>2 of 3</span>
          </Col>
          <Col className="py-2 border rounded">
            <span>3 of 3</span>
          </Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Equal-width columns can be broken into multiple lines, but there was a Safari flexbox bug that prevented this from working without an explicit flex-basis or border. There are workarounds for older browser versions, but they shouldn’t be necessary if you’re up-to-date.

Column
Column
Column
Column
import React from "react";

import { Container, Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row>
          <Col className="py-2 border rounded"><span>Column</span></Col>
          <Col className="py-2 border rounded"><span>Column</span></Col>
          <div className="w-100"></div>
          <Col className="py-2 border rounded"><span>Column</span></Col>
          <Col className="py-2 border rounded"><span>Column</span></Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Setting one column width

Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. You may use predefined grid classes (as shown below), grid mixins, or inline widths. Note that the other columns will resize no matter the width of the center column.

1 of 3
2 of 3 (wider)
3 of 3
1 of 3
2 of 3 (wider)
3 of 3
import React from "react";

import { Container, Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row>
          <Col className="py-2 border rounded">
            <span>1 of 3</span>
          </div>
          <Col xs="6" className="py-2 border rounded">
            <span>2 of 3 (wider)</span>
          </div>
          <Col className="py-2 border rounded">
            <span>3 of 3</span>
          </div>
        </Row>
        <Row>
          <Col className="py-2 border rounded">
            <span>1 of 3</span>
          </div>
          <Col xs="5" className="py-2 border rounded">
            <span>2 of 3 (wider)</span>
          </div>
          <Col className="py-2 border rounded">
            <span>3 of 3</span>
          </div>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Variable width content

Use {breakpoint}="auto" props to size columns based on the natural width of their content.

1 of 3
Variable width content
3 of 3
1 of 3
Variable width content
3 of 3
import React from "react";

import { Container, Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row className="justify-content-lg-center">
          <Col lg="2" className="py-2 border rounded">
            <span>1 of 3</span>
          </Col>
          <Col lg="auto" className="py-2 border rounded">
            <span>Variable width content</span>
          </Col>
          <Col lg="2" className="py-2 border rounded">
            <span>3 of 3</span>
          </Col>
        </Row>
        <Row>
          <Col className="py-2 border rounded">
            <span>1 of 3</span>
          </Col>
          <Col lg="auto" className="py-2 border rounded">
            <span>Variable width content</span>
          </Col>
          <Col lg="2" className="py-2 border rounded">
            <span>3 of 3</span>
          </Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Equal-width multi-row

Create equal-width columns that span multiple rows by inserting a .w-100 where you want the columns to break to a new line. Make the breaks responsive by mixing the .w-100 with some responsive display utilities.

Column
Column
Column
Column
import React from "react";

import { Container, Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row>
          <Col className="py-2 border rounded"><span>Column</span></Col>
          <Col className="py-2 border rounded"><span>Column</span></Col>
          <div className="w-100"></div>
          <Col className="py-2 border rounded"><span>Column</span></Col>
          <Col className="py-2 border rounded"><span>Column</span></Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Responsive props

Reactstrap’s grid includes five tiers of predefined props for building complex responsive layouts. Customize the size of your columns on extra small, small, medium, large, or extra large devices however you see fit.

Bootstrap breakpoints

For grids that are the same from the smallest of devices to the largest, use the Col and Col xs=* tags and props. Specify a numbered xs prop when you need a particularly sized column; otherwise, feel free to stick to blank Col tag.

Col
Col
Col
Col
Col
Col
import React from "react";

import { Container, Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row>
          <Col className="py-2 border rounded"><span>Col</span></Col>
          <Col className="py-2 border rounded"><span>Col</span></Col>
          <Col className="py-2 border rounded"><span>Col</span></Col>
          <Col className="py-2 border rounded"><span>Col</span></Col>
        </div>
        <Row>
          <Col xs="8" className="py-2 border rounded"><span>Col</span></Col>
          <Col xs="4" className="py-2 border rounded"><span>Col</span></Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Stacked to horizontal

Using a single set of .col-sm-* classes, you can create a basic grid system that starts out stacked and becomes horizontal at the small breakpoint (sm).

sm="8"
sm="4"
sm
sm
sm
import React from "react";

import { Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
        <Row>
          <Col sm="8" className="py-2 border rounded"><span>sm="8"</span></Col>
          <Col sm="4" className="py-2 border rounded"><span>sm="4"</span></Col>
        </Row>
        <Row>
          <Col sm className="py-2 border rounded"><span>sm</span></Col>
          <Col sm className="py-2 border rounded"><span>sm</span></Col>
          <Col sm className="py-2 border rounded"><span>sm</span></Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Mix and match

Don’t want your columns to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.

xs="12" md="8"
xs="6" md="4"
xs="6" md="4"
xs="6" md="4"
xs="6" md="4"
xs="6"
xs="6"
import React from "react";

import { Row, Col } from "reactstrap";

function Example(){
  return (
    <>
      <Container>
      {/* Stack the columns on mobile by making one full-width and the other half-width  */}
        <Row>
          <Col xs="12" md="8" className="py-2 border rounded"><span>xs="12" md="8"</span></Col>
          <Col xs="6" md="4" className="py-2 border rounded"><span>xs="6" md="4"</span></Col>
        </Row>

        {/* Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop  */}
        <Row>
          <Col xs="6" md="4" className="py-2 border rounded"><span>xs="6" md="4"</span></Col>
          <Col xs="6" md="4" className="py-2 border rounded"><span>xs="6" md="4"</span></Col>
          <Col xs="6" md="4" className="py-2 border rounded"><span>xs="6" md="4"</span></Col>
        </Row>

        {/* Columns are always 50% wide, on mobile and desktop */}
        <Row>
          <Col xs="6" className="py-2 border rounded"><span>xs="6"</span></Col>
          <Col xs="6" className="py-2 border rounded"><span>xs="6"</span></Col>
        </Row>
      </Container>
    </>
  );
}

export default Example;

Reactstrap Layout

For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.

Reactstrap Container

Containers are the most basic layout element in Reactstrap (Bootstrap) and are required when using our default grid system. Containers are used to contain, pad, and (sometimes) center the content within them. While Containers can be nested, most layouts do not require a nested Container.

Reactstrap (Bootstrap) comes with three different containers:

  • <Container>, which sets a max-width at each responsive breakpoint
  • <Container fluid>, which is width: 100% at all breakpoints
  • <Container fluid={breakpoint}>, which is width: 100% until the specified breakpoint