sagalbot / vue-select

Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
https://vue-select.org
MIT License
4.62k stars 1.33k forks source link

vue-select.css styles are not applied to the web component #1680

Closed n4ks closed 4 months ago

n4ks commented 1 year ago

Please respect maintainers time by filling in these sections. Your issue will likely be closed without this information.

Describe the bug When I work on a project in dev mode there is no problem, but as soon as I build an application as a web component, the styles are not applied. I managed to find that the problem is that the css variables in the vue-select.css file are in the :root pseudo-class and if I replace it with :host everything works fine. Honestly I have no idea how to fix this without changing the library styles manually.

Steps To Reproduce

  1. import vue-select.css (In my case, I do this in the scss file - @import 'vue-select/dist/vue-select.css';)
  2. Build project : "build": "vue-cli-service build --target wc --name weather-widget ./src/components/weather-widget.vue"
  3. Next I will attach two screenshots that show the difference in component behavior.

I also want to note that not only the styles that I override are broken, but in general all of the styles that use css variables from the file vue-select.css

Expected behavior Styles are applied after the web component is built.

Screenshots

  1. with :rootpseudo-class image
  2. with :host pseudo-class image
gazben commented 1 year ago

Did you find a solution to this?

gazben commented 1 year ago

Okay so the problem is the css variable overrides Explanation: https://stackoverflow.com/a/53240578

My code that solved the issue:


<script lang="ts">
import 'vue-select/dist/vue-select.css'
</script>

<style scoped>
.v-select::v-deep {
  --vs-controls-color: rgba(255, 255, 255, 0.2);
</style>
sagalbot commented 1 year ago

@n4ks I don't have any experience with web components unfortunately. If you could provide a https://codesandbox.io to demonstrate, that'd be much appreciated and maybe I can get that fixed.

github-actions[bot] commented 4 months ago

:tada: This issue has been resolved in version 3.20.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: