Skip to content

Instantly share code, notes, and snippets.

@heytulsiprasad
Created September 4, 2020 17:55
Show Gist options
  • Save heytulsiprasad/e8bae1eba7b90ef66b8b1b1ae0861d96 to your computer and use it in GitHub Desktop.
Save heytulsiprasad/e8bae1eba7b90ef66b8b1b1ae0861d96 to your computer and use it in GitHub Desktop.
Config tailwind to desktop first approach
module.exports = {
theme: {
extend: {},
screens: {
xl: { max: "1279px" },
// => @media (max-width: 1279px) { ... }
lg: { max: "1023px" },
// => @media (max-width: 1023px) { ... }
md: { max: "767px" },
// => @media (max-width: 767px) { ... }
sm: { max: "639px" },
// => @media (max-width: 639px) { ... }
},
},
variants: {},
plugins: [],
};
@cyrus01337
Copy link

cyrus01337 commented Dec 17, 2023

he basically added more breakpoints for using max-width 'pc first' instead of the original approach in tailwind with mix-with 'mobile first'

Appreciate you. ❤️

@hxadogar
Copy link

We can also use (Fixed-range) Breakpoints:

module.exports = {
  theme: {
    screens: {
      'sm': {'min': '640px', 'max': '767px'},
      // => @media (min-width: 640px and max-width: 767px) { ... }

      'md': {'min': '768px', 'max': '1023px'},
      // => @media (min-width: 768px and max-width: 1023px) { ... }

      'lg': {'min': '1024px', 'max': '1279px'},
      // => @media (min-width: 1024px and max-width: 1279px) { ... }

      'xl': {'min': '1280px', 'max': '1535px'},
      // => @media (min-width: 1280px and max-width: 1535px) { ... }

      '2xl': {'min': '1536px'},
      // => @media (min-width: 1536px) { ... }
    },
  }
}

Arbitrary value

<div class="min-[320px]:text-center max-[600px]:bg-sky-300">
  Hello world
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment