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

Example#

CoreUI's grid system uses a series of containers, rows, and columns to layout and align content. It's built with flexbox and is fully responsive. Below is an example and an in-depth explanation for how the grid system comes together.

One of three columns
One of three columns
One of three columns
1<CContainer>
2 <CRow>
3 <CCol sm="auto">One of three columns</CCol>
4 <CCol sm="auto">One of three columns</CCol>
5 <CCol sm="auto">One of three columns</CCol>
6 </CRow>
7</CContainer>

The above example creates three equal-width columns across all devices and viewports using our predefined grid classes. Those columns are centered in the page with the parent <CContainer>.

How it works#

Breaking it down, here's how the grid system comes together:

  • Our grid supports six responsive breakpoints. Breakpoints are based on min-width media queries, meaning they affect that breakpoint and all those above it (e.g., sm={4} applies to sm, md, lg, xl, and xxl). This means you can control container and column sizing and behavior by each breakpoint.

  • Containers center and horizontally pad your content. Use <CContainer> for a responsive pixel width, <CContainer fluid> for width: 100% across all viewports and devices, or a responsive container (e.g., <CContainer md>) for a combination of fluid and pixel widths.

  • Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins to ensure the content in your columns is visually aligned down the left side. Rows also support modifier classes to uniformly apply column sizing and gutter classes to change the spacing of your content.

  • Columns are incredibly flexible. There are 12 template columns available per row, allowing you to create different combinations of elements that span any number of columns. Column classes indicate the number of template columns to span (e.g., CCol xs={4} spans four). widths are set in percentages so you always have the same relative sizing.

  • Gutters are also responsive and customizable. Gutter classes are available across all breakpoints, with all the same sizes as our margin and padding spacing. Change horizontal gutters with xs|sm|md|lg|xl|xxl={{ gutterX: * }} classes, vertical gutters with xs|sm|md|lg|xl|xxl={{ gutterY: * }}, or all gutters with xs|sm|md|lg|xl|xxl={{ gutter: * }} classes. xs|sm|md|lg|xl|xxl={{ gutter: 0 }} is also available to remove gutters.

Be aware of the limitations and bugs around flexbox, like the inability to use some HTML elements as flex containers.

Grid options#

CoreUI's grid system can adapt across all six default breakpoints, and any breakpoints you customize. The six default grid tiers are as follow:

  • Extra small (xs)
  • Small (sm)
  • Medium (md)
  • Large (lg)
  • Extra large (xl)
  • Extra extra large (xxl)

As noted above, each of these breakpoints have their own container, unique class prefix, and modifiers. Here's how the grid changes across these breakpoints:

xs
<576px
sm
≥576px
md
≥768px
lg
≥992px
xl
≥1200px
xxl
≥1400px
Container max-widthNone (auto)540px720px960px1140px1320px
Class prefix<CCol xs=><CCol sm=><CCol md=><CCol lg=><CCol xl=><CCol xxl=>
# of columns12
Gutter width1.5rem (.75rem on left and right)
Custom guttersYes
NestableYes
Column orderingYes

Auto-layout columns#

Utilize breakpoint-specific column classes for easy column sizing without an explicit numbered class like <CCol sm={6}>.

Equal-width#

For example, here are two grid layouts that apply to every device and viewport, from xs to xxl. 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
1<CContainer>
2 <CRow>
3 <CCol>1 of 2</CCol>
4 <CCol>2 of 2</CCol>
5 </CRow>
6 <CRow>
7 <CCol>1 of 3</CCol>
8 <CCol>2 of 3</CCol>
9 <CCol>3 of 3</CCol>
10 </CRow>
11</CContainer>

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
1<CContainer>
2 <CRow>
3 <CCol>1 of 3</CCol>
4 <CCol xs={6}>2 of 3 (wider)</CCol>
5 <CCol>3 of 3</CCol>
6 </CRow>
7 <CRow>
8 <CCol>1 of 3</CCol>
9 <CCol xs={6}>2 of 3 (wider)</CCol>
10 <CCol>3 of 3</CCol>
11 </CRow>
12</CContainer>

Variable width content#

Use <CCol {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
1<CContainer>
2 <div className="row justify-content-md-center">
3 <CCol xs lg={2}>
4 1 of 3
5 </CCol>
6 <CCol md="auto">Variable width content</CCol>
7 <CCol xs lg={2}>
8 3 of 3
9 </CCol>
10 </div>
11 <CRow>
12 <CCol>1 of 3</CCol>
13 <CCol md="auto">Variable width content</CCol>
14 <CCol xs lg={2}>
15 3 of 3
16 </CCol>
17 </CRow>
18</CContainer>

Responsive classes#

CoreUI's grid includes six tiers of predefined classes 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.

All breakpoints#

For grids that are the same from the smallest of devices to the largest, use the <CCol> and <CCol xs={*}> classes. Specify a numbered class when you need a particularly sized column; otherwise, feel free to stick to <CCol>.

col
col
col
col
col-8
col-4
1<CContainer>
2 <CRow>
3 <CCol>col</CCol>
4 <CCol>col</CCol>
5 <CCol>col</CCol>
6 <CCol>col</CCol>
7 </CRow>
8 <CRow>
9 <CCol xs={8}>col-8</CCol>
10 <CCol xs={4}>col-4</CCol>
11 </CRow>
12</CContainer>

Stacked to horizontal#

Using a single set of <CCol sm={*}> classes, you can create a basic grid system that starts out stacked and becomes horizontal at the small breakpoint (sm).

col-sm-8
col-sm-4
col-sm
col-sm
col-sm
1<CContainer>
2 <CRow>
3 <CCol sm={8}>col-sm-8</CCol>
4 <CCol sm={4}>col-sm-4</CCol>
5 </CRow>
6 <CRow>
7 <CCol sm>col-sm</CCol>
8 <CCol sm>col-sm</CCol>
9 <CCol sm>col-sm</CCol>
10 </CRow>
11</CContainer>

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.

.col-md-8
.col-6 .col-md-4
.col-6 .col-md-4
.col-6 .col-md-4
.col-6 .col-md-4
.col-6
.col-6
1<CContainer>
2 <CRow>
3 <CCol md={8}>.col-md-8</CCol>
4 <CCol xs={6} md={4}>
5 .col-6 .col-md-4
6 </CCol>
7 </CRow>
8 <CRow>
9 <CCol xs={6} md={4}>
10 .col-6 .col-md-4
11 </CCol>
12 <CCol xs={6} md={4}>
13 .col-6 .col-md-4
14 </CCol>
15 <CCol xs={6} md={4}>
16 .col-6 .col-md-4
17 </CCol>
18 </CRow>
19 <CRow>
20 <CCol xs={6}>.col-6</CCol>
21 <CCol xs={6}>.col-6</CCol>
22 </CRow>
23</CContainer>

Row columns#

Use the responsive {breakpoint}={{ cols: * }} classes to quickly set the number of columns that best render your content and layout. Whereas normal <CCol xs={*}> classes apply to the individual columns (e.g., <CCol xs={4}>), the row columns classes are set on the parent <CRow> as a shortcut. With {breakpoint}={{ cols: 'auto' }} you can give the columns their natural width.

Use these row columns classes to quickly create basic grid layouts or to control your card layouts.

Column
Column
Column
Column
1<CContainer>
2 <CRow xs={{ cols: 2 }}>
3 <CCol>Column</CCol>
4 <CCol>Column</CCol>
5 <CCol>Column</CCol>
6 <CCol>Column</CCol>
7 </CRow>
8</CContainer>
Column
Column
Column
Column
1<CContainer>
2 <CRow xs={{ cols: 3 }}>
3 <CCol>Column</CCol>
4 <CCol>Column</CCol>
5 <CCol>Column</CCol>
6 <CCol>Column</CCol>
7 </CRow>
8</CContainer>
Column
Column
Column
Column
1<CContainer>
2 <CRow xs={{ cols: 'auto' }}>
3 <CCol>Column</CCol>
4 <CCol>Column</CCol>
5 <CCol>Column</CCol>
6 <CCol>Column</CCol>
7 </CRow>
8</CContainer>
Column
Column
Column
Column
1<CContainer>
2 <CRow xs={{ cols: 4 }}>
3 <CCol>Column</CCol>
4 <CCol>Column</CCol>
5 <CCol>Column</CCol>
6 <CCol>Column</CCol>
7 </CRow>
8</CContainer>
Column
Column
Column
Column
1<CContainer>
2 <CRow xs={{ cols: 4 }}>
3 <CCol>Column</CCol>
4 <CCol>Column</CCol>
5 <CCol xs={6}>Column</CCol>
6 <CCol>Column</CCol>
7 </CRow>
8</CContainer>
Column
Column
Column
Column
1<CContainer>
2 <CRow xs={{ cols: 1 }} sm={{ cols: 2 }} md={{ cols: 4 }}>
3 <CCol>Column</CCol>
4 <CCol>Column</CCol>
5 <CCol>Column</CCol>
6 <CCol>Column</CCol>
7 </CRow>
8</CContainer>

API#

CContainer#

1import { CContainer } from '@coreui/react'
2// or
3import CContainer from '@coreui/react/src/components/grid/CContainer'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the base component.string-
fluidSet container 100% wide, spanning the entire width of the viewport.boolean-
lgSet container 100% wide until large breakpoint.boolean-
mdSet container 100% wide until medium breakpoint.boolean-
smSet container 100% wide until small breakpoint.boolean-
xlSet container 100% wide until X-large breakpoint.boolean-
xxlSet container 100% wide until XX-large breakpoint.boolean-

CRow#

1import { CRow } from '@coreui/react'
2// or
3import CRow from '@coreui/react/src/components/grid/CRow'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the base component.string-
lgThe number of columns/offset/order on large devices (<1200px).{{ cols: 'auto' | number | string } | { gutter: number | string } | { gutterX: number | string } | { gutterY: number | string }}-
mdThe number of columns/offset/order on medium devices (<992px).{{ cols: 'auto' | number | string } | { gutter: number | string } | { gutterX: number | string } | { gutterY: number | string }}-
smThe number of columns/offset/order on small devices (<768px).{{ cols: 'auto' | number | string } | { gutter: number | string } | { gutterX: number | string } | { gutterY: number | string }}-
xlThe number of columns/offset/order on X-Large devices (<1400px).{{ cols: 'auto' | number | string } | { gutter: number | string } | { gutterX: number | string } | { gutterY: number | string }}-
xsThe number of columns/offset/order on extra small devices (<576px).{{ cols: 'auto' | number | string } | { gutter: number | string } | { gutterX: number | string } | { gutterY: number | string }}-
xxlThe number of columns/offset/order on XX-Large devices (≥1400px).{{ cols: 'auto' | number | string } | { gutter: number | string } | { gutterX: number | string } | { gutterY: number | string }}-

CCol#

1import { CCol } from '@coreui/react'
2// or
3import CCol from '@coreui/react/src/components/grid/CCol'
PropertyDescriptionTypeDefault
classNameA string of all className you want applied to the base component.string-
lgThe number of columns/offset/order on large devices (<1200px).{ 'auto' | number | string | boolean | { span: 'auto' | number | string | boolean } | { offset: number | string } | { order: 'first' | 'last' | number | string }}-
mdThe number of columns/offset/order on medium devices (<992px).{ 'auto' | number | string | boolean | { span: 'auto' | number | string | boolean } | { offset: number | string } | { order: 'first' | 'last' | number | string }}-
smThe number of columns/offset/order on small devices (<768px).{ 'auto' | number | string | boolean | { span: 'auto' | number | string | boolean } | { offset: number | string } | { order: 'first' | 'last' | number | string }}-
xlThe number of columns/offset/order on X-Large devices (<1400px).{ 'auto' | number | string | boolean | { span: 'auto' | number | string | boolean } | { offset: number | string } | { order: 'first' | 'last' | number | string }}-
xsThe number of columns/offset/order on extra small devices (<576px).{ 'auto' | number | string | boolean | { span: 'auto' | number | string | boolean } | { offset: number | string } | { order: 'first' | 'last' | number | string }}-
xxlThe number of columns/offset/order on XX-Large devices (≥1400px).{ 'auto' | number | string | boolean | { span: 'auto' | number | string | boolean } | { offset: number | string } | { order: 'first' | 'last' | number | string }}-