Grid system
Bootstrap’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 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.
Auto-layout columns
When no column widths are specified the Col
component will render equal width columns
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.
Variable width content
Set the column value (for any breakpoint size) to "auto"
to size columns based on the natural width of their content.
Responsive grids
The Col
lets you specify column widths across 5 breakpoint sizes (xs, sm, md, large, and xl). For every breakpoint, you can specify the amount of columns to span, or set the prop to <Col lg={true} />
for auto layout widths.
You can also mix and match breakpoints to create different grids depending on the screen size.
The Col
breakpoint props also have a more complicated object
prop form: {span: number, order: number, offset: number}
for specifying offsets and ordering affects.
You can use the `order` property to control the visual order of your content.
For offsetting grid columns you can set an `offset` value, or, for more general layout, use the margin class utilities.
API
Containerview source file
import Container from 'react-bootstrap/Container'
Copy import code for the Container componentName | Type | Default | Description |
---|---|---|---|
as | elementType | You can use a custom element for this component | |
fluid | boolean | false | Allow the Container to fill all of its available horizontal space. |
bsPrefix | string | 'container' | Change the underlying component CSS base class name and modifier class names prefix. This is an escape hatch for working with heavily customized bootstrap css. |
import Row from 'react-bootstrap/Row'
Copy import code for the Row componentName | Type | Default | Description |
---|---|---|---|
as | elementType | You can use a custom element type for this component. | |
noGutters | boolean | false | Removes the gutter spacing between |
bsPrefix | string | 'row' | Change the underlying component CSS base class name and modifier class names prefix. This is an escape hatch for working with heavily customized bootstrap css. |
import Col from 'react-bootstrap/Col'
Copy import code for the Col componentName | Type | Default | Description |
---|---|---|---|
as | elementType | You can use a custom element type for this component. | |
lg | true | "auto" | number | { span: true | "auto" | number, offset: number, order: number } | The number of columns to span on large devices (≥992px) | |
md | true | "auto" | number | { span: true | "auto" | number, offset: number, order: number } | The number of columns to span on medium devices (≥768px) | |
sm | true | "auto" | number | { span: true | "auto" | number, offset: number, order: number } | The number of columns to span on small devices (≥576px) | |
xl | true | "auto" | number | { span: true | "auto" | number, offset: number, order: number } | The number of columns to span on extra large devices (≥1200px) | |
xs | true | "auto" | number | { span: true | "auto" | number, offset: number, order: number } | The number of columns to span on extra small devices (<576px) | |
bsPrefix | string | 'col' | Change the underlying component CSS base class name and modifier class names prefix. This is an escape hatch for working with heavily customized bootstrap css. |