The Bootstrap Grid is a twelve-column, flexbox-based layout system recreated with Tailwind utilities. It provides a familiar row and column structure for building responsive designs.
The Bootstrap Grid uses containers, rows, and columns to create responsive layouts. It is built with flexbox and adapts to different screen sizes.
HTML
<div class='container text-center'>
<div class='row'>
<div class='col'>Column</div>
<div class='col'>Column</div>
<div class='col'>Column</div>
</div>
</div>Use breakpoint-specific column classes for easy sizing of columns without adding explicit numbered classes like .col-sm-6.
Use the .col class to create equal-width columns for every screen size.
HTML
<div class="container text-center">
<div class="row">
<div class="col">1 of 2</div>
<div class="col">2 of 2</div>
</div>
<div class="row">
<div class="col">1 of 3</div>
<div class="col">2 of 3</div>
<div class="col">3 of 3</div>
</div>
</div>Use the .col-auto class to size columns based on the natural width of their content.
HTML
<div class='container text-center'>
<div class='row md:justify-center mb-3'>
<div class='col lg:col-2'>1 of 3</div>
<div class='md:col-auto'>Variable width content</div>
<div class='col lg:col-2'>3 of 3</div>
</div>
<div class='row'>
<div class='col'>1 of 3</div>
<div class='md:col-auto'>Variable width content</div>
<div class='col lg:col-2'>3 of 3</div>
</div>
</div>Use responsive column classes to specify different column sizes for different screen sizes. Breakpoints are defined using minimum widths, meaning each one applies from that width upward. However, they can also be set with specific ranges based on project needs and preferences, in which case they’ll only apply within that range.
For example, .md:col-4 applies to medium devices (tablets) and above.
For grids that are the same across all breakpoints, use the .col and .col-{size} classes.
HTML
<div class="container text-center">
<div class="row">
<div class="col">col</div>
<div class="col">col</div>
<div class="col">col</div>
<div class="col">col</div>
</div>
<div class="row">
<div class="col-8">col-8</div>
<div class="col-4">col-4</div>
</div>
</div>Mix and match different breakpoint-specific column classes for different screen sizes.
HTML
<div class="container text-center">
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row">
<div class="md:col-8">.md:col-8</div>
<div class="col-6 md:col-4">.col-6 .md:col-4</div>
</div>
<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
<div class="row">
<div class="col-6 md:col-4">.col-6 .md:col-4</div>
<div class="col-6 md:col-4">.col-6 .md:col-4</div>
<div class="col-6 md:col-4">.col-6 .md:col-4</div>
</div>
<!-- Columns are always 50% wide, on mobile and desktop -->
<div class="row">
<div class="col-6">.col-6</div>
<div class="col-6">.col-6</div>
</div>
</div>Instead of specifying the number of columns per row, use the .row-cols-{number} classes to specify the number of columns per row. The grid will automatically lay out the columns evenly. .row-cols-auto can be used to set the number of columns based on the content.
HTML
<div class="container text-center">
<div class="row row-cols-2">
<div class="col">Column</div>
<div class="col">Column</div>
<div class="col">Column</div>
<div class="col">Column</div>
</div>
</div>HTML
<div class="container text-center">
<div class="row row-cols-auto">
<div class="col">Column</div>
<div class="col">Column</div>
<div class="col">Column</div>
<div class="col">Column</div>
</div>
</div>HTML
<div class="container text-center">
<div class="row row-cols-1 sm:row-cols-2 md:row-cols-4">
<div class="col">Column</div>
<div class="col">Column</div>
<div class="col">Column</div>
<div class="col">Column</div>
</div>
</div>Nesting is easy with the Bootstrap Grid. Just add a new .row and set of .col within an existing .col. This gives more control over the layout of the content.
HTML
<div class="container text-center">
<div class="row">
<div class="sm:col-3">Level 1: .sm:col-3</div>
<div class="sm:col-9">
<div class="row">
<div class="col-8 sm:col-6">Level 2: .col-8 .sm:col-6</div>
<div class="col-4 sm:col-6">Level 2: .col-4 .sm:col-6</div>
</div>
</div>
</div>
</div>Modify columns with options for alignment, ordering, and offsetting using the flexbox grid system. Column classes can also be used to control the width of non-grid elements.
Use the .items-start, .items-center, and .items-end classes to control vertical alignment.
HTML
<div class="container text-center">
<div class="row items-start">
<div class="col">One of three columns</div>
<div class="col">One of three columns</div>
<div class="col">One of three columns</div>
</div>
</div>
Use the .self-start, .self-center, and .self-end classes to control vertical alignment of individual columns.
HTML
<div class="container text-center">
<div class="row">
<div class="col self-start">One of three columns</div>
<div class="col self-center">One of three columns</div>
<div class="col self-end">One of three columns</div>
</div>
</div>
Apply the .justify-* classes to control horizontal alignment.
HTML
<div class="container text-center">
<div class="row justify-start">
<div class="col-4">One of two columns</div>
<div class="col-4">One of two columns</div>
</div>
<div class="row justify-center">
<div class="col-4">One of two columns</div>
<div class="col-4">One of two columns</div>
</div>
<div class="row justify-end">
<div class="col-4">One of two columns</div>
<div class="col-4">One of two columns</div>
</div>
</div>
Use .order-{number} classes to change the order of columns.
HTML
<div class="container text-center">
<div class="row">
<div class="col">First in DOM, no order applied</div>
<div class="col order-5">Second in DOM, with a larger order</div>
<div class="col order-1">Third in DOM, with an order of 1</div>
</div>
</div>
Grid columns can be offset in two ways: using responsive .offset-{size} grid classes or margin utilities. Grid classes provide offsets that match column sizes, while margin utilities are useful for flexible layouts where the offset width is variable.
Use .offset-{number} classes to move columns to the right. For example, .md:offset-4 moves a column over four columns on medium screens and larger.
HTML
<div class="container text-center">
<div class="row">
<div class="md:col-4">.md:col-4</div>
<div class="md:col-4 md:offset-4">.md:col-4 .md:offset-4</div>
</div>
<div class="row">
<div class="md:col-3 md:offset-3">.md:col-3 .md:offset-3</div>
<div class="md:col-3 md:offset-3">.md:col-3 .md:offset-3</div>
</div>
<div class="row">
<div class="md:col-6 md:offset-3">.md:col-6 .md:offset-3</div>
</div>
</div>
Gutters are the spaces between columns in the Bootstrap Grid system, used to create consistent spacing and alignment.
Use the .gx-{size} classes to set horizontal gutters between columns.
HTML
<div class="container text-center overflow-hidden">
<div class="row gx-12">
<div class="col">
<div>Custom column padding</div>
</div>
<div class="col">
<div>Custom column padding</div>
</div>
</div>
</div>Use the .gy-{size} classes to set vertical gutters between rows.
HTML
<div class="container text-center">
<div class="row gy-12">
<div class="col-6">
<div>Custom column padding</div>
</div>
<div class="col-6">
<div>Custom column padding</div>
</div>
<div class="col-6">
<div>Custom column padding</div>
</div>
<div class="col-6">
<div>Custom column padding</div>
</div>
</div>
</div>Use the .g-{size} classes to set both horizontal and vertical gutters.
HTML
<div class="container text-center">
<div class="row g-3">
<div class="col-6">
<div>Custom column padding</div>
</div>
<div class="col-6">
<div>Custom column padding</div>
</div>
<div class="col-6">
<div>Custom column padding</div>
</div>
<div class="col-6">
<div>Custom column padding</div>
</div>
</div>
</div>Gutter classes can be combined with .row-cols-{number} classes to create gutters between rows and columns.
HTML
<div class="container text-center">
<div class="row row-cols-2 lg:row-cols-3 g-3">
<div class="col">
<div>Row column</div>
</div>
<div class="col">
<div>Row column</div>
</div>
<div class="col">
<div>Row column</div>
</div>
<div class="col">
<div>Row column</div>
</div>
<div class="col">
<div>Row column</div>
</div>
<div class="col">
<div>Row column</div>
</div>
</div>
</div>Apply the .g-0 class to remove all gutters between rows and columns. This removes the padding from the immediate children .col-{size} and negative margins from .row.
HTML
<div class="row g-0 text-center">
<div class="md:col-6 md:col-8">.md:col-6 .md:col-8</div>
<div class="col-6 md:col-4">.col-6 .md:col-4</div>
</div>The Bootstrap Grid uses CSS variables for easy customization. Override these variables in the CSS to change the grid’s behavior.
--grid-gutter-x: 1.5rem;
--grid-gutter-y: 0px;
--grid-columns: 12;
--grid-row-columns: 6;