Bootstrap v5 flexbox grid system as a Tailwind CSS plugin.
npm i -D tailwind-bootstrap-grid
In tailwind.js
file:
module.exports = {
plugins: [require('tailwind-bootstrap-grid')()],
};
And don't forget to include components
and utilities
in your tailwind base
css file:
@tailwind preflight;
@tailwind components;
@tailwind utilities;
Check the repository for details.
Based on Bootstrap docs + live code edit.
1 of 22 of 21 of 32 of 33 of 3<div class="container"> <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>
1 of 32 of 3 (wider)3 of 31 of 32 of 3 (wider)3 of 3<div class="container"> <div class="row"> <div class="col">1 of 3</div> <div class="col-6">2 of 3 (wider)</div> <div class="col">3 of 3</div> </div> <div class="row"> <div class="col">1 of 3</div> <div class="col-5">2 of 3 (wider)</div> <div class="col">3 of 3</div> </div> </div>
1 of 3Variable width content3 of 31 of 3Variable width content3 of 3<div class="container"> <div class="row" style={{ justifyContent: 'center' }}> <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>
colcolcolcolcol-8col-4<div class="container"> <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>
sm:col-8sm:col-4sm:colsm:colsm:col<div class="container"> <div class="row"> <div class="sm:col-8">sm:col-8</div> <div class="sm:col-4">sm:col-4</div> </div> <div class="row"> <div class="sm:col">sm:col</div> <div class="sm:col">sm:col</div> <div class="sm:col">sm:col</div> </div> </div>
col-12 md:col-8col-6 md:col-4col-6 md:col-4col-6 md:col-4col-6 md:col-4col-6col-6<div class="container"> {/* Stack the columns on mobile by making one full-width and the other half-width */} <div class="row"> <div class="col-12 md:col-8">col-12 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>
ColumnColumnColumnColumn<div class="container"> <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>
ColumnColumnColumnColumn<div class="container"> <div class="row row-cols-3"> <div class="col">Column</div> <div class="col">Column</div> <div class="col">Column</div> <div class="col">Column</div> </div> </div>
ColumnColumnColumnColumn<div class="container"> <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>
ColumnColumnColumnColumn<div class="container"> <div class="row 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>
ColumnColumnColumnColumn<div class="container"> <div class="row row-cols-4"> <div class="col">Column</div> <div class="col">Column</div> <div class="col-6">Column</div> <div class="col">Column</div> </div> </div>
ColumnColumnColumnColumn<div class="container"> <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>
Level 1: sm:col-3Level 2: col-8 sm:col-6Level 2: col-4 sm:col-6<div class="container"> <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>
First in DOM, no order appliedSecond in DOM, with a larger orderThird in DOM, with an order of 1<div class="container"> <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>
First in DOM, ordered lastSecond in DOM, unorderedThird in DOM, ordered first<div class="container"> <div class="row"> <div class="col order-last">First in DOM, ordered last</div> <div class="col">Second in DOM, unordered</div> <div class="col order-first">Third in DOM, ordered first</div> </div> </div>
md:col-4md:col-4 md:offset-4md:col-3 md:offset-3md:col-3 md:offset-3md:col-6 md:offset-3<div class="container"> <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>
sm:col-5 md:col-6sm:col-5 sm:offset-2 md:col-6 md:offset-0sm:col-6 md:col-5 lg:col-6sm:col-6 md:col-5 md:offset-2 lg:col-6 lg:offset-0<div class="container"> <div class="row"> <div class="sm:col-5 md:col-6">sm:col-5 md:col-6</div> <div class="sm:col-5 sm:offset-2 md:col-6 md:offset-0"> sm:col-5 sm:offset-2 md:col-6 md:offset-0 </div> </div> <div class="row"> <div class="sm:col-6 md:col-5 lg:col-6">sm:col-6 md:col-5 lg:col-6</div> <div class="sm:col-6 md:col-5 md:offset-2 lg:col-6 lg:offset-0"> sm:col-6 md:col-5 md:offset-2 lg:col-6 lg:offset-0 </div> </div> </div>
Custom column paddingCustom column padding<div class="container"> <div class="row gx-5"> <div class="col">Custom column padding</div> <div class="col">Custom column padding</div> </div> </div>
Custom column paddingCustom column paddingCustom column paddingCustom column padding<div class="container"> <div class="row gy-5"> <div class="col-6">Custom column padding</div> <div class="col-6">Custom column padding</div> <div class="col-6">Custom column padding</div> <div class="col-6">Custom column padding</div> </div> </div>
Custom column paddingCustom column paddingCustom column paddingCustom column padding<div class="container"> <div class="row g-2"> <div class="col-6">Custom column padding</div> <div class="col-6">Custom column padding</div> <div class="col-6">Custom column padding</div> <div class="col-6">Custom column padding</div> </div> </div>
Row columnRow columnRow columnRow columnRow columnRow columnRow columnRow columnRow columnRow column<div class="container"> <div class="row row-cols-2 lg:row-cols-5 g-2 lg:g-3"> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> <div class="col">Row column</div> </div> </div>
sm:col-6 md:col-8col-6 md:col-4<div class="container"> <div class="row g-0"> <div class="sm:col-6 md:col-8">sm:col-6 md:col-8</div> <div class="col-6 md:col-4">col-6 md:col-4</div> </div> </div>