Tailwind doesn’t include purpose-built grid classes out of the box, but grid layouts are simple to build using the existing Flexbox and width utilities.
Basic Grids
Use the existing Flexbox and percentage width utilities to construct basic grids.
Responsive Grids
Use the responsive variants of the width utilities to build responsive grid layouts.
all
sm
md
lg
xl
Mixed Column Sizes
Mix different percentage width utilities to build mixed size grids.
Wrapping Columns
Add flex-wrap
to your column container to allow columns to wrap when they run out of room.
Column Spacing
Add a negative horizontal margin like -mx-2
to your column container and an equal horizontal padding like px-2
to each column to add gutters.
To prevent horizontal scrolling in full width layouts, add overflow-hidden
to another parent container, or compensate for the negative margin with matching horizontal padding.
Automatic Column Widths
Use flex-1
instead of an explicit width on your columns to have them size automatically to fill the row.
Column Order
Use flex-row-reverse
to reverse column order. Useful for two-column responsive layouts where the column on right should appear first on smaller screens.
Simple Offsets
Use auto margin utilities like ml-auto
and mr-auto
to offset columns in a row.