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

sl-divider doesn't render in SvelteKit app using Autoloader #2066

Closed
mato-a opened this issue Jun 13, 2024 · 3 comments
Closed

sl-divider doesn't render in SvelteKit app using Autoloader #2066

mato-a opened this issue Jun 13, 2024 · 3 comments
Labels
bug Things that aren't working right in the library.

Comments

@mato-a
Copy link

mato-a commented Jun 13, 2024

Describe the bug

sl-divider doesn't render in SvelteKit app using Autoloader

To Reproduce & Demo

Use Autoloader to install Shoelace in SvelteKit app and then try using <sl-divider></sl-divider>

The divider is not rendered as shown here: https://stackblitz.com/edit/sveltejs-kit-template-default-gt9s5b?file=src%2Froutes%2F%2Bpage.svelte

Using the same code using just plain html works fine.

Browser / OS

  • shoelace@2.15.1
  • firefox/chrome
  • windows
@mato-a mato-a added the bug Things that aren't working right in the library. label Jun 13, 2024
@mato-a mato-a changed the title <sl-divider> doesn't render in SvelteKit app using Autoloader sl-divider doesn't render in SvelteKit app using Autoloader Jun 13, 2024
@dvantuyl
Copy link

In your example, sl-divider isn't displaying because its intrinsic width in this flexbox context is zero. Minor CSS update will display the divider:

sl-divider { width: 100%; }

https://stackblitz.com/edit/sveltejs-kit-template-default-zwgaqx?file=src%2Froutes%2F%2Bpage.svelte

@mato-a
Copy link
Author

mato-a commented Jun 18, 2024

Thanks @dvantuyl 👍

I've tried it in my own project but it wasn't actually the issue. Even with width at 100% the divider just wasn't showing...

So I dug a little deeper and I was able to figure it out.
The issue in my project wasn't really related to Svelte but to Tailwindcss resets - https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
These were causing the border style of sl-divider to be overridden.
I was able to fix it just by adding !important to sl-divider default styles - https://github.com/shoelace-style/shoelace/blob/next/src/components/divider/divider.styles.ts:

sl-divider:not([vertical]) {
	border-top: solid var(--width) var(--color) !important;
}
sl-divider[vertical] {
	border-left: solid var(--width) var(--color) !important;
}

@mato-a mato-a closed this as completed Jun 18, 2024
@mato-a
Copy link
Author

mato-a commented Jul 11, 2024

related: #2088

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

2 participants