Tailwindcss: grid-gap only works if grid-template(-areas) is being used

Created on 22 Apr 2020  路  8Comments  路  Source: tailwindlabs/tailwindcss

I'm getting this warning when running vue-cli serve:

grid-gap only works if grid-template(-areas) is being used

postcss.config.js

const tailwindcss = require("tailwindcss");
const autoprefixer = require("autoprefixer");

module.exports = {
  plugins: [
    tailwindcss("./tailwind.config.js"),
    autoprefixer({
      add: true,
      grid: true
    }),
  ]
};

Tried tailwindcss versions 1.2 and 1.3.x
It's coming from @tailwind utilities;

Full warrning

Module Warning (from ./node_modules/postcss-loader/src/index.js):
Warning

(3:1) grid-gap only works if grid-template(-areas) is being used

 @ ./src/main.css 4:14-156 14:3-18:5 15:22-164
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.1.190:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

 warning  in ./src/main.css

Most helpful comment

Changed autoprefixer settings to:

autoprefixer({
      add: true,
      grid: false
    }),

And warnings are gone.

So it's basicaly just autoprefixer(),

All 8 comments

Changed autoprefixer settings to:

autoprefixer({
      add: true,
      grid: false
    }),

And warnings are gone.

So it's basicaly just autoprefixer(),

Yeah Tailwind's grid utilities aren't designed to be compatible with how Autoprefixer tries to polyfill grid support (it's too limiting), so you will see warnings if you enable Autoprefixer's grid features with Tailwind.

You can either disable that feature in Autoprefixer, or disable Tailwind's grid utilities by setting all of the relevant plugins to false in your corePlugins config 馃憤

I just hit this as well. I set grid: false. No more errors.

I just hit this as well. I set grid: false. No more errors.

grid: false disables vendor prefixes for grids. For example, if you disable this, your grid properties won't be able to work in IE and old Edge browsers.

So, @adamwathan, this is not a good solution :shrug:

Tailwind's grid utilities do not support IE. If you need to support IE, I recommend using the target: 'IE11' option in Tailwind which will remove these utilities, and you can use Flexbox or write your own grid CSS that is IE-compatible.

@adamwathan I am currently having problems with Safari and their lack of support for grid-gap. Have you encountered this? Should I use flexbox instead if I want to support safari

Safari does support grid-gap. I recommend opening a new discussion thread with a link to an example so it's easier to troubleshoot what the problem could be:

Open a new discussion thread

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benface picture benface  路  3Comments

chintanbanugaria picture chintanbanugaria  路  3Comments

lamberttraccard picture lamberttraccard  路  3Comments

spyric picture spyric  路  3Comments

chasegiunta picture chasegiunta  路  3Comments