Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending screens config breaks arbitrary values #12489

Open
stafyniaksacha opened this issue Nov 27, 2023 · 5 comments
Open

Extending screens config breaks arbitrary values #12489

stafyniaksacha opened this issue Nov 27, 2023 · 5 comments

Comments

@stafyniaksacha
Copy link

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>
@wongjn
Copy link
Contributor

wongjn commented Nov 27, 2023

Hi! Thank you for the report. This is a known limitation, see #9558 (comment) for details.

@adamwathan
Copy link
Member

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.

@joshuabaker
Copy link

@adamwathan I’m noticing that this also breaks when targeting breakpoints, not just for arbitrary values. It might be worth noting this alongside the custom media queries documentation.

Am I right in thinking that it’s not currently possible to do height-based (or other) media queries using Tailwind as well as being able to use either arbitrary width breakpoints and/or breakpoint targeting?

@wongjn
Copy link
Contributor

wongjn commented May 15, 2024

Indeed as per #9558, any non-"simple" breakpoints will stop any max-* or min-* variants from working, which would in turn make targeting breakpoints not possible (in the form in the documentation).

It's possible to do height-based media queries using Tailwind as well as being able to use either arbitrary width breakpoints and/or breakpoint targeting. You could:

@joshuabaker
Copy link

@wongjn Big thank you for the guidance 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants