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
Border utilities reset has conflicting specificity with ::slotted pseudo element #1298
Comments
Are you sure it's not w3c/csswg-drafts#2290 |
I dont have a conflicting |
I just ran into the same problem. It's not limited to slotted elements - it's any border style applied within the shadow dom. A dirty workaround is to add !important to the @apply border styles. I hate :host {
@apply border border-black !important;
} I suppose a really painful workaround that avoids component.css @tailwind base;
@tailwind components;
@tailwind utilities;
:host {
@apply border border-black;
} |
Can someone actually provide a reproduction of this so I can look at it? Never played around with any of this shadow DOM stuff. |
Yeah I'll try to get an example for ya, my component lib is proprietary so I cant publish any of that stuff unfortunately, but maybe I can make a codepen |
An example of this issue is shown in the 'card' component (src/components/card). The border styles are not applied due to this:
generated from the preflight styles. |
Thanks Jason! I'm currently home sick feeling like I got run over by a truck. Thanks for picking this issue up so maybe we can get to a resolution |
I'm wondering if this might make sense as an Thoughts? |
Something like this: modify-base.plugin.js module.exports = ({ addUtilities, addComponents, addBase, e, prefix, config }) => {
const baseStyles = {
'html': {
fontFamily: config('theme.fontFamily.sans')
},
...config('extend.base')
}
addBase(baseStyles)
}; And then disable the preflight tailwind.config.js
UPDATE
Ignore that. My mistake. |
No plans to do anything about this right now so going to close. We can't improve this experience without introducing a breaking change that would be painful for the majority of the user base so I think just have to live with it until someone thinks of a solution that doesn't break things for existing users. |
For anyone still looking for a solution, the following has worked for a webcomponent we have with a the component CSS in the shadow dom :host([has-border]) {
border-bottom: var(--ui5-listitem-border-bottom);
} Reverting the effect of the preflight so that the @tailwind base;
ui5-li {
all: revert-layer;
} From MDN:
|
https://github.com/tailwindcss/tailwindcss/blob/v1.1.4/src/plugins/css/preflight.css#L101
is the reset in question.
In my project, I have a UI component library that is composed entirely of composable shadow dom UI components (built with StencilJS) and exposed as web components. I'm in the process of converting the styling of these components to tailwind and I discovered that when i tried to use the
::slotted()
pseudo element to style children components of a parent group component that contains a slot, that the reset lines above were ALWAYS higher specificity than my own shadow dom style declarations no matter what I tried. My workaround thus far has been to turn off the preflight and include just normalizecss myself for now, but I thought it worth mentioning the issue I faced.Here's a code sample of what i was trying to do:
with this setup, and using stencil's build process (with postcss and a pretty standard tailwind.config.js) the reset
*, ::after, ::before
was unable to be overwritten by the::slotted()
styles, so the border utilities have no effectThe text was updated successfully, but these errors were encountered: