-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Breaking change after upgrade related to border-color #5039
Comments
@adamwathan I figured out why this is happening. Turns out it is related to some invalid selectors. Say you have a custom style like: .form-control {
&[type="file"] {
@apply bg-white border focus:outline-none focus:ring-1 cursor-pointer px-3 py-2;
}
&::file-selector-button {
@apply rounded-none border-0 border-gray-300 border-solid px-3 py-2 -mx-3 -my-2 bg-gray-100 leading-6 transition pointer-events-none;
margin-inline-end: theme('spacing.3');
border-inline-end-width: 1px;
}
&:hover::file-selector-button {
@apply bg-gray-200;
}
&::-webkit-file-upload-button {
@apply rounded-none border-0 border-gray-300 border-solid px-3 py-2 -mx-3 -my-2 bg-gray-100 leading-6 transition pointer-events-none;
margin-inline-end: theme('spacing.3');
border-inline-end-width: 1px;
}
&:hover::-webkit-file-upload-button {
@apply bg-gray-200;
}
} For some reason const path = require("path")
module.exports = ctx => ({
plugins: [
require("postcss-import")({
path: path.resolve(__dirname + "/frontend/styles")
}),
require("tailwindcss")(`frontend/styles/tailwind.${path.basename(ctx.file, ".css")}.js`),
require("postcss-nested"),
require("postcss-flexbugs-fixes"),
require("postcss-color-mod-function")({unresolved: "warn"}),
require("postcss-preset-env")({
stage: 3,
autoprefixer: {
flexbox: "no-2009"
}
})
]
}) Edit: To fix this problem I had to move the border rules and expand them manually: @@ -4,9 +4,10 @@
}
&::file-selector-button {
- @apply rounded-none border-0 border-gray-300 border-solid px-3 py-2 -mx-3 -my-2 bg-gray-100 leading-6 transition pointer-events-none;
+ @apply rounded-none px-3 py-2 -mx-3 -my-2 bg-gray-100 leading-6 transition pointer-events-none;
margin-inline-end: theme('spacing.3');
border-inline-end-width: 1px;
+ border: 0 theme('colors.gray.300') solid;
}
&:hover::file-selector-button {
@@ -14,12 +15,13 @@
}
&::-webkit-file-upload-button {
- @apply rounded-none border-0 border-gray-300 border-solid px-3 py-2 -mx-3 -my-2 bg-gray-100 leading-6 transition pointer-events-none;
+ @apply rounded-none px-3 py-2 -mx-3 -my-2 bg-gray-100 leading-6 transition pointer-events-none;
margin-inline-end: theme('spacing.3');
border-inline-end-width: 1px;
+ border: 0 theme('colors.gray.300') solid;
}
&:hover::-webkit-file-upload-button {
@apply bg-gray-200;
}
-}
\ No newline at end of file
+} |
Got it, thanks for the extra context! The solution in your case is to migrate to our official nesting plugin — the root of the issue here is that when Tailwind is parsing out the The solution is to make sure you un-nest your CSS before Tailwind sees it, and use our official Update your config file to look like this: const path = require("path")
module.exports = ctx => ({
plugins: [
require("postcss-import")({
path: path.resolve(__dirname + "/frontend/styles")
}),
+ require("tailwindcss/nesting"),
require("tailwindcss")(`frontend/styles/tailwind.${path.basename(ctx.file, ".css")}.js`),
- require("postcss-nested"),
require("postcss-flexbugs-fixes"),
require("postcss-color-mod-function")({unresolved: "warn"}),
require("postcss-preset-env")({
stage: 3,
+ // postcss-preset-env includes nesting as well, you don't need it twice
+ features: {
+ 'nesting-rules': false
+ },
autoprefixer: {
flexbox: "no-2009"
}
})
]
}) You can read about our nesting stuff here: https://tailwindcss.com/docs/using-with-preprocessors#nesting |
@adamwathan Thanks for the feedback! But another issue came up after applying your suggestions.
You can reproduce the same bug using this repository: https://github.com/rainerborene/tailwindcss-bug |
I tried to disable .form-switch .form-check-input:checked ~ .form-check-label:after {
@apply transform translate-x-full border-brand-base;
} |
Since 2.2.3 my borders are black too and I've lost some shadows. I am using Angular and Tailwind is generating this extra CSS:
|
I also get black borders with the following code which is defined in an import inside an .Button--rounded {
@apply inline-flex items-center justify-center border rounded-full shadow-sm;
} When I move the import to the bottom of my entry css file (outside of Also, the border color of the divide utility turned black. This was without using |
@rainerborene Quick fix for your .form-switch .form-check-input:checked ~ .form-check-label::after {
@apply transform translate-x-full border-brand-base;
} I consider this a bug though since both syntaxes are valid in CSS, so will make a note to fix. |
Reverted the main piece of the changes that cause this stuff for v2.2.7, check that out and see if it helps. Hopefully can resolve the underlying issues and bring these improvements back soon. |
@adamwathan Thanks for reverting it back! I think you should reconsider these performance changes and make it optional. We have been using universal selectors for a long time and didn't notice any rendering slowness (at least in our case). |
Yeah we'll see, the main problem is it was causing the Tailwind CSS homepage to take over 3 seconds to load in Safari, and now it loads in a few hundred milliseconds. Mainly effects pages with a huge number of DOM nodes (our homepage is almost 7000). |
Hey! All of this should be resolved in the latest insiders build ( // tailwind.config.js
module.exports = {
experimental: { optimizeUniversalDefaults: true },
// ...
} I just merged proper support for the legacy |
@adamwathan You rock! I'm going to test it as soon as possible. |
What version of Tailwind CSS are you using?
v2.2.6
What build tool (or framework if it abstracts the build tool) are you using?
webpack 5.37.0
What version of Node.js are you using?
v14.1.0
What browser are you using?
Chrome
What operating system are you using?
Linux
Describe your issue
This line has a huge impact on the default styles and it was removed on the recent version. Most Tailwind examples out there uses something like:
And it was used by the
hr
tag as well. Please, revert this change if possible. Thank you!The text was updated successfully, but these errors were encountered: