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

Allow completely user-specified CSS #110

Open
succinct opened this issue Oct 28, 2019 · 5 comments
Open

Allow completely user-specified CSS #110

succinct opened this issue Oct 28, 2019 · 5 comments

Comments

@succinct
Copy link

succinct commented Oct 28, 2019

Is there a way to prevent loading the standard vue-tags-input css, so that we can specify exactly how we want to style tags? Alternately, maybe we could get a slot for the tag wrapper (<li>) itself?

@al3d
Copy link

al3d commented Jan 7, 2020

While it's possible to override the default styling by adding !important to the styles, this isn't the ideal behaviour - it has been briefly addressed in issue #108 but for me still leaves a bitter taste in the mouth.

I'd like to see vue-tags-input shipped with a "bare-minimum" set of styles that takes care of the most important aspects such as positioning etc. while not making assumptions for commonly-customised aspects such as text and background colours, margins and paddings etc.

I believe the easiest way to allow this is to drop the scoped attribute in the reference to the (s)css file in the vue-tags-input.vue file. Unless there's a good reason for it, I don't see why the scoped attribute is there - it would allow overriding the styles quite easily in a CSS-specificity-friendly manner. To override styles you'd only need to write CSS with slightly higher specificity to what is given i.e.

.container .vue-tags-input .ti-tag {
    background-color: indigo;
}

would override the default .vue-tags-input .ti-tag styles - without the need to add !important.

Another option would be to not include the css in the vue-tags-input.vue file, allowing the css to be imported directly from the library. This will probably break backwards compatibility but would offer the obvious flexibility in customisation, however without the bare-minimum CSS.

Lastly, another option would be to extract the template html into its own file, allowing you to import what you need (ref).

@quinhone
Copy link

quinhone commented Apr 2, 2020

Hi, I changed the colors directly in the vue-tags-socket.scss file inside the node-modules folder, but still the background color did not change and kept the default colors

@jconti
Copy link

jconti commented Sep 3, 2020

I needed to override max-width with !important. I think these parameters should be specified outside, or in this case with flex.

@ilyen85
Copy link

ilyen85 commented May 11, 2021

You just have to make the selector more specific, no need to use !important-s.

For e.g:

<style lang="sass">
.tags_input_field
	.vue-tags-input.vue-tags-input
		max-width: 100%

This will be specific enough to set 100% as a max width

so basically wrap the whole thing in div with the class tags_input_field or anything you would like, than double the class name to make it more specific.

Screenshot 2021-05-11 at 13 10 00

@jpamorgan
Copy link

jpamorgan commented May 25, 2021

@ilyen85 is correct. I went through all of my styles and added the data attribute to each of the classnames to match the specificity of the native styles and was successfully able to override any styles I wanted.

Here are some examples of the selectors I used:

vue-tags-input[data-v-61d92e31] {}
.vue-tags-input[data-v-61d92e31] .ti-new-tag-input[data-v-61d92e31] {}
...

My final product:

Styled inputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants