-
-
Notifications
You must be signed in to change notification settings - Fork 997
Change styles of multi select #287
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
Comments
Styles are not scoped. Please look into https://github.com/monterail/vue-multiselect/blob/2.0/src/Multiselect.vue |
@shentao
In the generated HTML only the outer div of vue-multiselect has this data attribute attached. The child divs doesn't have these classes attached. So my styles are not getting attached to the div with class multiselect__tags |
@shentao Looks like it is same as this issue: deep selector |
My suggestion would be to use another style tag, as a Vue component can have multiple style blocks. <style scoped>
// your component styles
</style>
<style>
.your_custom_class .multiselect__tags
// stuff
</style> |
This is not a good solution. There are situations at which a user would want to change the styles for only one multiselect and leave all the others with their default styles. If you add in a style that is not scoped to that component, then it will affect all multiselect styles that are in the same parent/structural component and not in the individual components. For instance, I have ParentComponent.vue with two different components that I created myself. ComponentA.vue and ComponentB.vue. If both have a vue-multiselect in it and I only want to change the styles for ComponentA.vue's multiselect and NOT change ComponentB.vue's multiselect styles, then this is not possible. The only option I would have is to fork off of this node-module, modify and release, and then use the modified version for the one component that I want the styles to change and then keep the original node-module the same. The issue with this is that ComponentA.vue would no longer get updates from any new releases with the vue-multiselect node module. I would much rather prefer to see a property that would allow us to change styles within this component rather than forcing us to default all multiselect styles to our custom style if we only want one instance of the vue-multiselect styles to be changed. @shentao Please would you be able to create a feature request card to have this functionality added in. V/R |
If anyone is looking for a solution that uses scoped styles, but targets multiselect elements (or other elements out of scope), check out the Deep Selectors functionality built into vue-loader's scoped css feature: <style lang="css" scoped>
.your_custom_class >>> .multiselect__tags {
// stuff
}
</style> Or in SCSS: <style lang="scss" scoped>
.your_custom_class::v-deep .multiselect {
.multiselect__tags {
// stuff
}
}
</style> |
Any updates about this? Currently I need to change multiselect styles. |
Hm I tried to use this syntax But doesn't works |
Sorry my trouble |
you can edit the main style file in the node modules |
This suggestion would not work because as soon as you perform another npm install, your changes would then be over written by the original values. You should never be altering anything within the node modules folder because of this. Although, it is possible to extend the component and make your own alterations, but then that comes with it's own set of potential issues. |
i custom my multiselect to follow bootstrap 4 default style
|
Hey. I use modular styles and the exact naming of the class that needs to be modernized (why so? - because the internal naming of the class in my project is hashed and css options will not be added). <style lang="stylus" module="$s">
.multiselect
// IT WORK
// hide List is empty when use tagging and search
[class="multiselect__content-wrapper"]
display: none
// not working
.multiselect__content-wrapper
display: none
</style> |
This works amazingly just make sure not to have scoped in your style tag :) |
Here's the solution ( copy this just after your </script> , this way you get access to the css classess :
|
Hello! I did this to match style of the bootstrap 5 input field.
|
hi, has anyone ever integrated Multiselect with Tailwind css. I ask because if so it would be easier to integrate the "dark" mode. The management of custom css in v3 is clear but it is not easy to integrate the rest. If anyone has already faced the problem or found a solution, please share here. Thank you |
@MATTOFIRE I would say you would need to put in some upfront work of translating the existing CSS into compatible Tailwind using the .multiselect__select {
@apply <tailwind-classes-here>
} |
Hello and thank you for the useful library 😊 In my Vue SPA, I'm using PostCSS to manage styles. I'm figuring out how this solution influences the build process because some developers don't support using What do you think? <template>
<VueMultiselect class="multiselect" />
</template>
<script setup lang="ts" ns>
import VueMultiselect from 'vue-multiselect';
</script>
<style lang="postcss" module>
.multiselect {
:global(.multiselect__tags) {
padding: 0.275rem;
background-color: var(--color-gray-soft);
}
:global(.multiselect__tag) {
background-color: var(--color-white);
color: var(--color-gray-dark);
}
}
</style> |
any simple soluciont to the problem |
Hi I need to change the border-radius of .multiselect__tags class. I think the whole styles are scoped so my styles are not getting added. Is there any way to achieve this?
The text was updated successfully, but these errors were encountered: