Quick reference

Class
Properties
grid-flow-rowgrid-auto-flow: row;
grid-flow-colgrid-auto-flow: column;
grid-flow-row-densegrid-auto-flow: row dense;
grid-flow-col-densegrid-auto-flow: column dense;

Basic usage

Controlling grid element placement

Use the grid-flow-{keyword} utilities to control how the auto-placement algorithm works for a grid layout.

01
02
03
04
05
<div class="grid grid-flow-row-dense grid-cols-3 grid-rows-3 ...">
  <div class="col-span-2">01</div>
  <div class="col-span-2">02</div>
  <div>03</div>
  <div>04</div>
  <div>05</div>
</div>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:grid-flow-row to only apply the grid-flow-row utility on hover.

<div class="grid grid-flow-col hover:grid-flow-row">
  <!-- ... -->
</div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:grid-flow-row to apply the grid-flow-row utility at only medium screen sizes and above.

<div class="grid grid-flow-col md:grid-flow-row">
  <!-- ... -->
</div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.