Flexbox & Grid

Grid Auto Columns

Utilities for controlling the size of implicitly-created grid columns.

Quick reference

Class
Properties
auto-cols-autogrid-auto-columns: auto;
auto-cols-mingrid-auto-columns: min-content;
auto-cols-maxgrid-auto-columns: max-content;
auto-cols-frgrid-auto-columns: minmax(0, 1fr);

Basic usage

Sizing implicitly-created grid columns

Use the auto-cols-{size} utilities to control the size of implicitly-created grid columns.

  1. <div class="grid grid-flow-col auto-cols-max">
  2. <div>01</div>
  3. <div>02</div>
  4. <div>03</div>
  5. </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:auto-cols-min to only apply the auto-cols-min utility on hover.

  1. <div class="grid grid-flow-col auto-cols-max hover:auto-cols-min">
  2. <!-- ... -->
  3. </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:auto-cols-min to apply the auto-cols-min utility at only medium screen sizes and above.

  1. <div class="grid grid-flow-col auto-cols-max md:auto-cols-min">
  2. <!-- ... -->
  3. </div>

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


Using custom values

Customizing your theme

By default, Tailwind includes four general purpose grid-auto-columns utilities. You can customize these values by editing theme.gridAutoColumns or theme.extend.gridAutoColumns in your tailwind.config.js file.

tailwind.config.js

  1. module.exports = { theme: { extend: { gridAutoColumns: { '2fr': 'minmax(0, 2fr)', } } }}

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off grid-auto-columns value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

  1. <div class="auto-cols-[minmax(0,_2fr)]">
  2. <!-- ... -->
  3. </div>

Learn more about arbitrary value support in the arbitrary values documentation.