-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Description
What version of Tailwind CSS are you using?
2.2.4
What build tool (or framework if it abstracts the build tool) are you using?
Gulp and tailwindcss-cli
What version of Node.js are you using?
v14.17.2
What browser are you using?
N/A
What operating system are you using?
Windows 10
Reproduction repository
https://play.tailwindcss.com/6re84tZQjw?file=css
Describe your issue
Noticed this recently and just curious if this is the intended/expected behavior. In JIT mode, when using @apply, responsive variants (e.g. md:) are output as separate, duplicate CSS rules rather than combined into one (as is the case with non-responsive rules). Note: This is the case whether one uses multiple @apply rules or combines all styles into one.
Input:
CONFIG
const colors = require('tailwindcss/colors')
module.exports = {
mode: 'jit',
theme: {
extend: {},
},
variants: {},
plugins: [],
}
HTML
<div class="nav-main">
<a href="#" class="nav-item">nav</a>
</div>
CSS
@tailwind base;
@tailwind components;
@tailwind utilities;
.nav-main {
@apply bg-gray-200 w-full;
@apply md:w-1/2 md:px-5 md:bg-blue-200;
}
.nav-item {
@apply uppercase text-sm tracking-wider font-semibold flex py-2 px-4 border-b-2 border-transparent;
@apply md:text-blue-600 md:font-bold md:tracking-widest;
}
or
.nav-main {
@apply bg-gray-200 w-full md:w-1/2 md:px-5 md:bg-blue-200;
}
.nav-item {
@apply uppercase text-sm tracking-wider font-semibold flex py-2 px-4 border-b-2 border-transparent md:text-blue-600 md:font-bold md:tracking-widest;
}
Output:
.nav-main {
width: 100%;
--tw-bg-opacity: 1;
background-color: rgba(229, 231, 235, var(--tw-bg-opacity));
}
@media (min-width: 768px) {
.nav-main {
width: 50%;
}
.nav-main {
--tw-bg-opacity: 1;
background-color: rgba(191, 219, 254, var(--tw-bg-opacity));
}
.nav-main {
padding-left: 1.25rem;
padding-right: 1.25rem;
}
}
.nav-item {
display: flex;
border-bottom-width: 2px;
border-color: transparent;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
padding-left: 1rem;
padding-right: 1rem;
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
}
@media (min-width: 768px) {
.nav-item {
font-weight: 700;
}
.nav-item {
letter-spacing: 0.1em;
}
.nav-item {
--tw-text-opacity: 1;
color: rgba(37, 99, 235, var(--tw-text-opacity));
}
}
Output without mode: 'jit'
.nav-main {
width: 100%;
--tw-bg-opacity: 1;
background-color: rgba(229, 231, 235, var(--tw-bg-opacity));
}
@media (min-width: 768px) {
.nav-main {
width: 50%;
--tw-bg-opacity: 1;
background-color: rgba(191, 219, 254, var(--tw-bg-opacity));
padding-left: 1.25rem;
padding-right: 1.25rem;
}
}
.nav-item {
display: flex;
border-bottom-width: 2px;
border-color: transparent;
padding-left: 1rem;
padding-right: 1rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
}
@media (min-width: 768px) {
.nav-item {
font-weight: 700;
letter-spacing: 0.1em;
--tw-text-opacity: 1;
color: rgba(37, 99, 235, var(--tw-text-opacity));
}
}
https://play.tailwindcss.com/6re84tZQjw?file=css
I'm a huge fan of tailwindcss and newly getting familiar with JIT so I appreciate any help or clarification that is offered!
Metadata
Metadata
Assignees
Labels
No labels