tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Extending screens config breaks arbitrary values

Open stafyniaksacha opened this issue 5 months ago • 2 comments

What version of Tailwind CSS are you using?

v3.3.5

What build tool (or framework if it abstracts the build tool) are you using?

Vite 4

What version of Node.js are you using?

v18.0.0

What browser are you using?

Chrome, Safari, or N/A

What operating system are you using?

Windows / Linux

Reproduction URL

https://play.tailwindcss.com/fvlYPhEOPh?file=config

Describe your issue

When extending screens in tailwind configuration (using min/max or raw), it breaks arbitrary values:

// tailwind.config.js

/** @type {import('tailwindcss').Config} */
export default {
  theme: {
    extend: {
      screens: {
        '2xl': { min: '1536px' }, // fixed range breaks arbitrary values
        tall: { raw: '(min-height: 800px)' }, // raw breaks arbitrary values
      },
    },
  },
  plugins: [],
}

Makes this don't work:

<div class="min-[600px]:text-red-400  max-[600px]:text-sky-300">
  Test arbitray screen values
</div>

stafyniaksacha avatar Nov 27 '23 07:11 stafyniaksacha

Hi! Thank you for the report. This is a known limitation, see https://github.com/tailwindlabs/tailwindcss/pull/9558#user-content-restrictions for details.

wongjn avatar Nov 27 '23 08:11 wongjn

Yeah this is currently by design because we can't properly sort media queries and get the correct precedence behavior when applying the classes in your HTML when they are mixed like this, but I'm going to leave this open for a bit as a reminder to look into it again and sort of remember where the challenges were and see if we can't do something a bit better.

One idea is to group the media queries by "type" for sorting purposes and keep the min/max ones grouped with the regular min-width-based media queries for example. Could do the same thing for the mixed unit problem possibly — you'd get strange results but if they are deterministic perhaps that's all we need.

adamwathan avatar Nov 27 '23 11:11 adamwathan