8

I registered a custom breakpoint ('mymd': '962px') and after that all breakpoints that are lower in width do not work

tailwind.config.js

module.exports = {
  purge: [],
  darkMode: 'media', // or 'media' or 'class'
  theme: {
    screens: {
      'sm': '640px',
      'md': '768px',
      'mymd': '962px',
      'lg': '1024px',
      'xl': '1280px',
      '2xl': '1536px',
    },
  },
  variants: {
    extend: {},
  },
  plugins: [

  ],
}

html

<div class="sm:bg-red-900 
            md:bg-yellow-900 
            mymd:bg-gray-900 
            lg:bg-green-900 
            xl:bg-blue-900 
            2xl:bg-indigo-900 
            h-screen w-full">
2xl, xl, lg and mymd work correctly, but md & sm doesn't work

img - https://ibb.co/D4x3vF8

1

4 Answers 4

7

I cannot create a new breakpoint between the default breakpoint, but I did this

theme

const defaultTheme = require('tailwindcss/defaulttheme');

module.exports = {
  purge: [],
  darkMode: 'media', // or 'media' or 'class'
  theme: {
    screens: {
      'xs': '425px',
      ...defaultTheme.screens,
    },
    extend: {
      screens: {
        '3xl': '1920px',
      },
    },
  },
  variants: {
    extend: {},
  },
  plugins: [

  ],
}

HTML

<div class="sm:bg-red-900
            lg:bg-green-900
            3xl:bg-indigo-900
            h-screen w-full">
</div>
Sign up to request clarification or add additional context in comments.

Comments

5

Try extending,

theme: {
 screens: {
   'sm': '640px',
   'md': '768px',
   'lg': '1024px',
   'xl': '1280px',
   '2xl': '1536px',
  },
  extend: {
    screens: {
      'mymd': '962px'
    }
  },
},

Update:

Seems to be working fine - check this sandbox You can view the result here

2 Comments

@Alex updated my answer, overrides for default classes should go under screen, new classes should go under extend.screens
Same problem =(
0

Extending and writing the screens in ascending order solved it for me

theme: {
container: {
  center: true,
  padding: "2rem",
  screens: {
    "2xl": "1400px",
  },
},
extend: {
  screens: {
    "xs" : "376px",
  },

Comments

0

you can also set break-points directly in css:

//app.css
@import "tailwindcss";
@theme {
  --breakpoint-xs: 30rem;  // <= custom break-points
  --breakpoint-2xl: 100rem;
  --breakpoint-3xl: 120rem;
}

<div class="grid xs:grid-cols-2 3xl:grid-cols-6">
  <!-- ... -->
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.