tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Add `scripting` variants

Open lukewarlow opened this issue 8 months ago • 10 comments

This adds two variants for the scripting media query. noscript for when JavaScript is disabled and scripting for when it's enabled.

lukewarlow avatar Aug 30 '23 21:08 lukewarlow

Hey thanks for this one! I do like to try and stay on the bleeding edge with what we support in Tailwind but since this isn’t even in Chromium yet I think I’d rather wait a bit longer before adding a first-class API for it and including it in the documentation.

So going to close for now but let’s revisit when browser support improves a bit?

adamwathan avatar Sep 06 '23 12:09 adamwathan

Oh I should have pointed out I've just implemented this in Chrome. So it'll be in version 120. @adamwathan

lukewarlow avatar Sep 06 '23 12:09 lukewarlow

Absolutely fine if you'd still rather wait but yeah worth being aware as of November this should be in all 3 browsers :)

lukewarlow avatar Sep 06 '23 12:09 lukewarlow

Alright alright, will reopen 😅 Biggest blocker on all of these PRs for what it's worth is the immense documentation effort, but going to see if someone here can make time for it next week.

adamwathan avatar Sep 07 '23 20:09 adamwathan

That's absolutely fine, take as long as you need!

lukewarlow avatar Sep 07 '23 22:09 lukewarlow

Just as an fyi I chucked together a docs PR for the variant PRs https://github.com/tailwindlabs/tailwindcss.com/pull/1674 No worries if you'd rather get someone to go through it all themselves just thought I'd give it a go in case it helped :)

lukewarlow avatar Sep 08 '23 16:09 lukewarlow

In case if someone waiting this PR to be merged I've made temporary workaround based on custom media queries:

theme: {
  extend: {
    screens: {
      'noscript': { 'raw': '(scripting: none)' },
    },
  },
},

Usage:

<div class="noscript:hidden">
  Some JS dependant feature
</div>
<div class="noscript:block hidden">
  no js detected sorry :(
</div>

mnik01 avatar Jan 14 '24 10:01 mnik01

Alternatively https://github.com/lukewarlow/tailwind-mq includes it.

lukewarlow avatar Jan 14 '24 13:01 lukewarlow

Hey!

You might have noticed that I forced pushed to this branch. The reason is because the PR now uses next as the base branch which is our working branch for Tailwind CSS v4. In other words, the feature you implemented here is now written in the new codebase.

The code is ported as-is, so no API changes of your feature happened while moving it to the new codebase.

I also made sure to add you as a co-author because you still deserve all the credit 💪

RobinMalfait avatar Apr 17 '24 21:04 RobinMalfait

I do like to try and stay on the bleeding edge with what we support in Tailwind but [...] I rather wait a bit longer [...] let’s revisit when browser support improves a bit?

https://caniuse.com/?search=scripting

Global 81.82%

sdavids avatar Apr 18 '24 08:04 sdavids