question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addComponents strips out classes when using media queries and breakpoint prefixes.

See original GitHub issue

What version of Tailwind CSS are you using?

3.0.22

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

Next.js 12.0.10

What version of Node.js are you using?

v14.18.1

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction URL

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

Describe your issue

I’m trying to update my plugin to fix some bugs and support version 3 (https://www.npmjs.com/package/tailwind-container-break-out), but it seems that the addComponents and addUtiliites methods aren’t working with media queries? I’ve done endless debugging and still can’t pinpoint it, but I’m thinking it might have something to do with the classes’ prefixedIdentifier not being unique?

Using the addUtilties method adds the multiple versions of the CSS declarations with nested media queries, and using addComponents seems to strip out other versions of the class if they are prefixed with .sm:\\ , .md:\\ etc.

I have basically replicated the way that the .container class works in TailwindCSS core, but adding media queries. It seemed to work in the previous version, although I was using addUtilities, and this was still adding nested media queries.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adamwathancommented, Feb 17, 2022

Yeah that’s intended in the sense that we haven’t bothered to optimize it away 👍🏻 It is still totally valid CSS and does what you’d expect.

Going to close this since it sounds like it’s figured out!

0reactions
LucidNinjacommented, Feb 17, 2022

Ok perfect! This has definitely solved my problem. That said - even in your example it seems to be producing nested media queries, which I’m not sure is intended behaviour (even though it’s working). If you inspect the md:container-half or lg:container-half classes, you’ll see that it’s producing something like this:

@media (min-width: 768px)
@media (min-width: 1024px)
.md\:container-half {
    width: calc(1024px / 2);
}

However, this is the same if you use Tailwind’s core container class when prefixed with a breakpoint:

@media (min-width: 1024px)
@media (min-width: 1536px)
.lg\:container {
    max-width: 1536px;
}

I’m not sure if this is intended?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media Queries for Standard Devices - CSS-Tricks
Gmail strips out the head of your message so media queries wont work. The best you can do is build a fluid layout...
Read more >
Media Query BreakPoint on mobile not working - Stack Overflow
I'm creating an email with the below breakpoints, but I'm having some difficulties with the breakpoints. The breakpoint below is not working on...
Read more >
tailwindcss - UNPKG
143, - Properly extract classes with arbitrary values in arrays and classes ... 444, - Fix issue with media queries not being generated...
Read more >
Unreal Engine 5.0 Release Notes
Leverage game-changing fidelity: Bring incredibly immersive and realistic interactive experiences to life with groundbreaking new features like Nanite and Lumen ...
Read more >
Omeka Documentation - Read the Docs
Table directory inside the directory containing the models. The name of the table class should be the model's class name prefixed with Table_, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found