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

Styling #102

Open
gg4u opened this issue Aug 21, 2020 · 1 comment
Open

Styling #102

gg4u opened this issue Aug 21, 2020 · 1 comment
Labels
vue Only applies to the autocomplete-vue package
Projects
Milestone

Comments

@gg4u
Copy link

gg4u commented Aug 21, 2020

I am using single files components ( <template><script><style>) - I failed to override the styling.

https://github.com/trevoreyre/autocomplete/tree/master/packages/autocomplete-vue#styling-and-customization

Scoped or not, the styles are not applied. However I do see that classes and ids are correctly placed on dom

<style scoped>
 .autocomplete-input { display: none } // style is not applied
</style>

Same behavior when importing the css in the style part:

<style scoped>
@import url('https://cdn.jsdelivr.net/npm/@trevoreyre/autocomplete-js@2.2.0/dist/style.css');  // will not apply styles
</style>

The only way is to import the css in the script, like:

 import '@trevoreyre/autocomplete-vue/dist/style.css'

Can you debrief how to scope styling for the component and its functional template ?

@trevoreyre
Copy link
Owner

The included styles are intentionally opinionated, and are meant to be imported in your JS, like your last example.

To override the styles yourself, you'd need to add a class to the component wherever you are applying the scoped styles. If you are using the default slot you can control the rendering of the entire component, and add your scoped classes to each of the child elements as well.

If you're not using the slot, you can add a classname to the root component, and use deep selectors to style the child elements inside the autocomplete component. Additionally you can use the baseClass prop to change the class of the child elements in the component.

@trevoreyre trevoreyre added the vue Only applies to the autocomplete-vue package label Sep 1, 2020
@trevoreyre trevoreyre added this to To do in v4.0 via automation Sep 1, 2020
@trevoreyre trevoreyre added this to the v3.0 milestone Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue Only applies to the autocomplete-vue package
Projects
v4.0
  
To do
Development

No branches or pull requests

2 participants