Replies: 2 comments
This comment was marked as spam.
This comment was marked as spam.
-
|
Hello! This is a known compatibility issue when mixing Tailwind v3 and v4 preflight styles. Here are the recommended solutions: Solution 1: Disable Preflight in v3 Design System module.exports = {
corePlugins: {
preflight: false,
},
}Solution 2: Use CSS Layer Scoping /* In your design system's main CSS file */
@layer design-system {
/* Your component styles here */
.btn { /* ... */ }
.card { /* ... */ }
}
/* Remove @tailwind base from design system CSS */Solution 3: Build Design System Without Base Styles // Design system build configuration
module.exports = {
content: ['./src/**/*.{js,ts,jsx,tsx}'],
corePlugins: {
preflight: false, // Critical: disable preflight
},
plugins: [
// Your plugins
],
}Solution 4: CSS Import Order Management /* app.css */
@import "tailwindcss"; /* v4 first */
@import "design-system/dist/assets/style.css"; /* v3 components after */Solution 5: Enhanced Workaround with Layer Isolation /* In your main app CSS */
@layer base {
/* Reset v3 border conflicts */
*:not(.design-system *):not(svg):not(svg *) {
border-color: inherit;
border-style: inherit;
border-width: inherit;
}
}
/* Import design system after base reset */
@import "design-system/dist/assets/style.css";Solution 6: Build-Time Component Isolation // postcss.config.js for design system
module.exports = {
plugins: [
require('postcss-prefix-selector')({
prefix: '.design-system',
transform: function (prefix, selector, prefixedSelector) {
if (selector.includes('html') || selector.includes('body')) {
return selector;
}
return prefixedSelector;
},
}),
],
}Recommended Approach: If you cannot modify the design system, Solution 4 with careful import ordering combined with Solution 5 for conflict resolution provides the best temporary fix. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Tailwind team 👋
I'm facing a compatibility issue when importing a precompiled design system built with Tailwind v3 into a project using Tailwind v4.
Setup
Problem
Once imported, several Tailwind v4 utilities stop working properly — e.g.:
Cause
Tailwind v3 preflight sets global border defaults:
Tailwind v4’s preflight, however, resets borders differently:
The v3 preflight overrides v4’s expectations, breaking CSS variable–based utilities like border-red-500.
Temporary workaround
As a temporary fix, I’m using the following override to revert the v3 preflight impact:
This restores most v4 utility behavior, but it’s not ideal or sustainable.
Questions
Thanks for your time and guidance 🙏
Beta Was this translation helpful? Give feedback.
All reactions