Skip to content

Instantly share code, notes, and snippets.

@heytulsiprasad
Created September 4, 2020 17:55
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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: [],
};
@won5572
Copy link

won5572 commented Apr 29, 2022

It's good idea.

@heytulsiprasad
Copy link
Author

It's good idea.

Yes, I always start with this approach.

@Prathamesh-Dukare
Copy link

aww, awesome stuff! my problem with desktop first is sorted

@heguerack
Copy link

Thank you! I will try it

@DonUggioni
Copy link

This works like a charm! Thank you!

@hannaofsweden
Copy link

hannaofsweden commented Mar 2, 2023

Containers will not work as expected unless you add something like this to your global stylesheet:

@layer base {
  .container {
    @apply max-w-[1280px] xl:max-w-[1024px] lg:max-w-[768px] md:max-w-[640px];
  }
}

@eroffa
Copy link

eroffa commented Apr 12, 2023

Improvement

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./src/**/*.{html,js}'],
  theme: {
    screens: {
      '2xl': {'max': '1535px'},
      'xl': {'max': '1279px'},
      'lg': {'max': '1023px'},
      'md': {'max': '767px'},
      'sm': {'max': '639px'},
    },
    container: {
      center: true,
      padding: '2rem',
    },
  },
  plugins: [],
}
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
    .container {
        @apply max-w-[1535px] xl:max-w-[1279px] lg:max-w-[1023px] md:max-w-[767px] sm:max-w-[639px];
    }
}

@layer components {}
@layer utilities {}

Copy link

ghost commented Oct 8, 2023

very nice idea for indian work

@cyrus01337
Copy link

@eroffa It's been a while since you've posted this so my bad if it's too late to ask.

Could you explain why you made the changes that you did to the original config?

@HamzaHamani
Copy link

@eroffa It's been a while since you've posted this so my bad if it's too late to ask.

Could you explain why you made the changes that you did to the original config?

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

@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. ❤️

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