Grid Auto Columns

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

Default class 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);

Usage

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>1</div>
  3. <div>2</div>
  4. <div>3</div>
  5. </div>

Responsive

To control the grid-auto-columns property at a specific breakpoint, add a {screen}: prefix to any existing grid-auto-columns utility. 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. <div>1</div>
  3. <div>2</div>
  4. <div>3</div>
  5. </div>

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

Customizing

By default, Tailwind includes four general purpose grid-auto-columns utilities. You can customize these in the theme.gridAutoColumns section of your tailwind.config.js file.

  1. // tailwind.config.js
  2. module.exports = {
  3. theme: {
  4. extend: {
  5. gridAutoColumns: {
  6. '2fr': 'minmax(0, 2fr)',
  7. }
  8. }
  9. }
  10. }

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

Variants

By default, only responsive variants are generated for grid-auto-columns utilities.

You can control which variants are generated for the grid-auto-columns utilities by modifying the gridAutoColumns property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. extend: {
  5. // ...
  6. + gridAutoColumns: ['hover', 'focus'],
  7. }
  8. }
  9. }

Disabling

If you don’t plan to use the grid-auto-columns utilities in your project, you can disable them entirely by setting the gridAutoColumns property to false in the corePlugins section of your config file:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + gridAutoColumns: false,
  6. }
  7. }

←Grid Auto Flow Grid Auto Rows→

Edit this page on GitHub