Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
TailwindCss's mobile breakpoints do not work

I am building a custom navbar in Gatsby using TailwindCss for styling. For reference I am following a tutorial on YouTube which's code can be found here.

When I use the mobile breakpoints as prefix like in the example below only the div saying "mobile" works as it should be:

Layout.js

<nav>
  <div className={"flex"}>
    <div className={"hidden md:flex"}>desktop</div>
    <div className={"md:hidden"}>mobile</div>
  </div>
</nav>

tailwind.config.js

module.exports = {
  content: ["./public/**/*.html", "./src/**/*.{js,jsx,ts,tsx,vue}"],
  darkMode: "class",
  theme: {},
  plugins: []
};

styles/global.css

@tailwind base;
@tailwind components;
@tailwind screens;
@tailwind utilities;

The output "desktop" should be shown when the text "mobile" vanishes but for some reason it doesn't. Am I doing something wrong or is there a problem with Tailwind?

enter image description here

EDIT: Reproduction example here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The problem seems to be in your global.css file.

You should not add the @tailwind screens;. Since you are using the latest TailwindCSS, @tailwind screens; was deprecated since 2.2 in JIT mode and it's now named: @tailwind variants;

Tailwind Changelog

As of v2.2, the @tailwind screens directive has been renamed to @tailwind variants, since it is now the injection point for all variants, not just responsive variants.

Some more info on when the @tailwind variants; should be added:

The @tailwind variants feature is considered an advanced escape hatch and we recommend omitting it by default. You should only use it if your project won't work properly without it, which is only ever really true if you are introducing Tailwind to a legacy system with a very fragile existing CSS codebase that has styles that absolutely need to be at the very end of the stylesheet for things to work.

Also, according to the Tailwind installation with Gatsby instructions You should not add the @tailwind variants;

That being said, you should not need it in this case so, by just removing it in you global.css file will fix the issue.

Your new global.css file should be:

@tailwind base;
@tailwind components;
@tailwind utilities;

Here is a working CodeSandbox

about 4 years ago · Juan Pablo Isaza Denunciar

0

Problem solved after I have noticed that the autoprefixer plugin was missing in the postcss.config.js. Just redid the installation for Gatsby.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda