Skip to content
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

Divider border gets overwritten by TailwindCSS preflight #2088

Open
KonnorRogers opened this issue Jun 24, 2024 · 9 comments
Open

Divider border gets overwritten by TailwindCSS preflight #2088

KonnorRogers opened this issue Jun 24, 2024 · 9 comments
Labels
upstream An upstream issue is blocking the issue.

Comments

@KonnorRogers
Copy link
Collaborator

KonnorRogers commented Jun 24, 2024

Describe the bug

<sl-divider>'s border is getting overwritten by TailwindCSS preflight CSS

To Reproduce

https://codepen.io/paramagicdev/pen/VwOdKqP?editors=1000

Screenshots

Screenshot 2024-06-24 at 4 25 02 PM

Browser / OS

  • OS: Mac
  • Browser: all
  • Browser version: all

Additional information

This is a result of the * selector having more specificity than :host. luckily it only affects borders set in a :host block, but its still annoying.

Users can use border: revert-layer on the specific component, but the browser support is atrocious.

sl-divider {
  border: revert-layer;
}

https://caniuse.com/?search=revert-layer

The other option is for them to recreate the :host selectors.

@KonnorRogers KonnorRogers added bug Things that aren't working right in the library. wontfix Bugs that are either by design or won't be fixed for a specific reason. and removed wontfix Bugs that are either by design or won't be fixed for a specific reason. labels Jun 24, 2024
@KonnorRogers
Copy link
Collaborator Author

@jusko I added a discussion to Tailwind here:

tailwindlabs/tailwindcss#13891

fingers crossed there's some way we can resolve this.

@jusko
Copy link

jusko commented Jun 25, 2024

Thanks @KonnorRogers. I'll be using the workaround you suggested of recreating the :host selectors for now. Will update if anything further related crops up.

@ChellappanRajan
Copy link
Contributor

Hi @KonnorRogers, I'm curious to know why we are not renaming the --width and --height CSS properties. I believe this could solve the issue. Thank you

@KonnorRogers
Copy link
Collaborator Author

KonnorRogers commented Jun 26, 2024

Hi @KonnorRogers, I'm curious to know why we are not renaming the --width and --height CSS properties. I believe this could solve the issue. Thank you

Not sure I follow by "renaming"

Those variables get set in the :host selector so they're scoped to the component. Any styling we do of the border will be rewritten by the * selector, because * has higher specificity than :host.

:host {
--color: var(--sl-panel-border-color);
--width: var(--sl-panel-border-width);
--spacing: var(--sl-spacing-medium);
}

@ChellappanRajan
Copy link
Contributor

Hi @KonnorRogers, I'm curious to know why we are not renaming the --width and --height CSS properties. I believe this could solve the issue. Thank you

Not sure I follow by "renaming"

Those variables get set in the :host selector so they're scoped to the component. Any styling we do of the border will be rewritten by the * selector, because * has higher specificity than :host.

:host {
--color: var(--sl-panel-border-color);
--width: var(--sl-panel-border-width);
--spacing: var(--sl-spacing-medium);
}

Instead of reassigning --color: var(--sl-panel-border-color), we can use border-top: solid var(--sl-panel-border-width) var(--color) directly"

@KonnorRogers
Copy link
Collaborator Author

Hi @KonnorRogers, I'm curious to know why we are not renaming the --width and --height CSS properties. I believe this could solve the issue. Thank you

Not sure I follow by "renaming"
Those variables get set in the :host selector so they're scoped to the component. Any styling we do of the border will be rewritten by the * selector, because * has higher specificity than :host.

:host {
--color: var(--sl-panel-border-color);
--width: var(--sl-panel-border-width);
--spacing: var(--sl-spacing-medium);
}

Instead of reassigning --color: var(--sl-panel-border-color), we can use border-top: solid var(--sl-panel-border-width) var(--color) directly"

That shouldn't make a difference. The problem will will still remain that * has more specificity than :host {}

@claviska claviska added upstream An upstream issue is blocking the issue. and removed bug Things that aren't working right in the library. labels Oct 28, 2024
@marcuslimdw
Copy link
Contributor

@claviska, would you accept a PR to add a note to the sl-divider documentation that:

  • this may happen when using Tailwind with Shoelace
  • a workaround is available?

If so, is there any particular format you'd want that information to be in? I don't recall any other such caveats being documented for other elements.

@claviska
Copy link
Member

@marcuslimdw that's probably a good idea in the meantime. You can add a callout to the divider page wherever it seems appropriate. The syntax for that looks like this:

:::tip
This test will be shown in a callout on the website.
:::

@marcuslimdw
Copy link
Contributor

Created #2356.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream An upstream issue is blocking the issue.
Projects
None yet
Development

No branches or pull requests

5 participants