Columns

Learn how to modify columns with a handful of options for alignment, ordering, and offsetting thanks to our flexbox grid system.

How they work#

  • Columns build on the grid's flexbox architecture. Flexbox means we have options for changing individual columns and modifying groups of columns at the row level. You choose how columns grow, shrink, or otherwise change.

  • When building grid layouts, all content goes in columns. The hierarchy of Bootstrap React's grid goes from container to row to column to your content. On rare occasions, you may combine content and column, but be aware there can be unintended consequences.

  • Bootstrap React includes predefined components for creating fast, responsive layouts. With six breakpoints and a dozen columns at each grid tier, we have dozens of components already built for you to create your desired layouts. This can be disabled via Sass if you wish.

Alignment#

Use flexbox alignment utilities to vertically and horizontally align columns.

Vertical alignment#

One of three columns
One of three columns
One of three columns
One of three columns
One of three columns
One of three columns
One of three columns
One of three columns
One of three columns
1<CContainer>
2 <CRow className="align-items-start">
3 <CCol>One of three columns</CCol>
4 <CCol>One of three columns</CCol>
5 <CCol>One of three columns</CCol>
6 </CRow>
7 <CRow className="align-items-center">
8 <CCol>One of three columns</CCol>
9 <CCol>One of three columns</CCol>
10 <CCol>One of three columns</CCol>
11 </CRow>
12 <CRow className="align-items-end">
13 <CCol>One of three columns</CCol>
14 <CCol>One of three columns</CCol>
15 <CCol>One of three columns</CCol>
16 </CRow>
17</CContainer>
One of three columns
One of three columns
One of three columns
1<CContainer>
2 <CRow>
3 <CCol className="align-self-start">One of three columns</CCol>
4 <CCol className="align-self-center">One of three columns</CCol>
5 <CCol className="align-self-end">One of three columns</CCol>
6 </CRow>
7</CContainer>

Horizontal alignment#

One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
One of two columns
1<CContainer>
2 <CRow className="justify-content-start">
3 <CCol xs={4}>One of two columns</CCol>
4 <CCol xs={4}>One of two columns</CCol>
5 </CRow>
6 <CRow className="justify-content-center">
7 <CCol xs={4}>One of two columns</CCol>
8 <CCol xs={4}>One of two columns</CCol>
9 </CRow>
10 <CRow className="justify-content-end">
11 <CCol xs={4}>One of two columns</CCol>
12 <CCol xs={4}>One of two columns</CCol>
13 </CRow>
14 <CRow className="justify-content-around">
15 <CCol xs={4}>One of two columns</CCol>
16 <CCol xs={4}>One of two columns</CCol>
17 </CRow>
18 <CRow className="justify-content-between">
19 <CCol xs={4}>One of two columns</CCol>
20 <CCol xs={4}>One of two columns</CCol>
21 </CRow>
22 <CRow className="justify-content-evenly">
23 <CCol xs={4}>One of two columns</CCol>
24 <CCol xs={4}>One of two columns</CCol>
25 </CRow>
26</CContainer>

Column wrapping#

If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.

.col-9
.col-4
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
.col-6
Subsequent columns continue along the new line.
1<CContainer>
2 <CRow>
3 <CCol xs={9}>.col-9</CCol>
4 <CCol xs={4}>
5 .col-4
6 <br />
7 Since 9 + 4 = 13 &gt; 12, this 4-column-wide div gets wrapped onto a new line as one
8 contiguous unit.
9 </CCol>
10 <CCol xs={6}>
11 .col-6
12 <br />
13 Subsequent columns continue along the new line.
14 </CCol>
15 </CRow>
16</CContainer>

Column breaks#

Breaking columns to a new line in flexbox requires a small hack: add an element with width: 100% wherever you want to wrap your columns to a new line. Normally this is accomplished with multiple <CRow>s, but not every implementation method can account for this.

.col-6 .col-sm-3
.col-6 .col-sm-3
.col-6 .col-sm-3
.col-6 .col-sm-3
1<CContainer>
2 <CRow>
3 <CCol xs={6} sm={3}>
4 .col-6 .col-sm-3
5 </CCol>
6 <CCol xs={6} sm={3}>
7 .col-6 .col-sm-3
8 </CCol>
9 <div className="w-100"></div>
10 <CCol xs={6} sm={3}>
11 .col-6 .col-sm-3
12 </CCol>
13 <CCol xs={6} sm={3}>
14 .col-6 .col-sm-3
15 </CCol>
16 </CRow>
17</CContainer>

You may also apply this break at specific breakpoints with our responsive display utilities.

.col-6 .col-sm-4
.col-6 .col-sm-4
.col-6 .col-sm-4
.col-6 .col-sm-4
1<CContainer>
2 <CRow>
3 <CCol xs={6} sm={4}>
4 .col-6 .col-sm-4
5 </CCol>
6 <CCol xs={6} sm={4}>
7 .col-6 .col-sm-4
8 </CCol>
9 <div className="w-100 d-none d-md-block"></div>
10 <CCol xs={6} sm={4}>
11 .col-6 .col-sm-4
12 </CCol>
13 <CCol xs={6} sm={4}>
14 .col-6 .col-sm-4
15 </CCol>
16 </CRow>
17</CContainer>

Reordering#

Order props#

Use xs|sm|md|lg|xl|xxl={{ order: 1-5 }} props for controlling the visual order of your content. These props are responsive, so you can set the order by breakpoint (e.g., xs={{ order: 1}} md={{ order: 2}}). Includes support for 1 through 5 across all six grid tiers.

First in DOM, no order applied
Second in DOM, with a larger order
Third in DOM, with an order of 1
1<CContainer>
2 <CRow>
3 <CCol>First in DOM, no order applied</CCol>
4 <CCol xs={{ span: true, order: 5 }}>Second in DOM, with a larger order</CCol>
5 <CCol xs={{ span: true, order: 1 }}>Third in DOM, with an order of 1</CCol>
6 </CRow>
7</CContainer>

There are also responsive xs|sm|md|lg|xl|xxl={{ order: 'first' }} and xs|sm|md|lg|xl|xxl={{ order: 'last' }} props that change the order of an element by applying order: -1 and order: 6, respectively. These values can also be intermixed with the numbered xs|sm|md|lg|xl|xxl={{ order: 1-5 }} values as needed.

First in DOM, ordered last
Second in DOM, unordered
Third in DOM, ordered first
1<CContainer>
2 <CRow>
3 <CCol xs={{ span: true, order: 'last' }}>First in DOM, ordered last</CCol>
4 <CCol>Second in DOM, unordered</CCol>
5 <CCol xs={{ span: true, order: 'first' }}>Third in DOM, ordered first</CCol>
6 </CRow>
7</CContainer>

Offsetting columns#

You can offset grid columns in two ways: our responsive xs|sm|md|lg|xl|xxl={{ offset: 0-12 }} grid props and our margin utilities. Grid props are sized to match columns while margins are more useful for quick layouts where the width of the offset is variable.

Offset prop#

Move columns to the right using md={{ offset: * }} props. These props increase the left margin of a column by * columns. For example, md={{ offset: 4 }} moves .col-md-4 over four columns.

.col-md-4
.col-md-4 .offset-md-4
.col-md-3 .offset-md-3
.col-md-3 .offset-md-3
.col-md-6 .offset-md-3
1<CContainer>
2 <CRow>
3 <CCol md={4}>.col-md-4</CCol>
4 <CCol md={{ span: 4, offset: 4 }}>.col-md-4 .offset-md-4</CCol>
5 </CRow>
6 <CRow>
7 <CCol md={{ span: 3, offset: 3 }}>.col-md-3 .offset-md-3</CCol>
8 <CCol md={{ span: 3, offset: 3 }}>.col-md-3 .offset-md-3</CCol>
9 </CRow>
10 <CRow>
11 <CCol md={{ span: 6, offset: 3 }}>.col-md-6 .offset-md-3</CCol>
12 </CRow>
13</CContainer>
.col-sm-5 .col-md-6
.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0
.col-sm-6 .col-md-5 .col-lg-6
.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
1<CContainer>
2 <CRow>
3 <CCol sm={5} md={6}>
4 .col-sm-5 .col-md-6
5 </CCol>
6 <CCol sm={{ span: 5, offset: 2 }} md={{ span: 6, offset: 0 }}>
7 .col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0
8 </CCol>
9 </CRow>
10 <CRow>
11 <CCol sm={6} md={5} lg={6}>
12 .col-sm-6 .col-md-5 .col-lg-6
13 </CCol>
14 <CCol sm={6} md={{ span: 5, offset: 2 }} lg={{ span: 6, offset: 0 }}>
15 .col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
16 </CCol>
17 </CRow>
18</CContainer>

Margin utilities#

You can use margin utilities like .me-auto to force sibling columns away from one another.

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

Standalone column component#

The <CCol> component can also be used outside a <CRow> to give an element a specific width. Whenever column component are used as non direct children of a row, the paddings are omitted.

.col-3: width of 25%
.col-sm-9: width of 75% above sm breakpoint
1<CCol xs={3} className="bg-light p-3 border">
2 .col-3: width of 25%
3</CCol>
4<CCol sm={9} className="bg-light p-3 border">
5 .col-sm-9: width of 75% above sm breakpoint
6</CCol>

API#

CCol#

1import { CCol } from '@coreui/bootstrap-react'
2// or
3import CCol from '@coreui/bootstrap-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 }}-