bestguy / sveltestrap

Bootstrap 4 & 5 components for Svelte
https://sveltestrap.js.org
MIT License
1.3k stars 183 forks source link

Not recognizing use of CSS selectors on `Col` #400

Closed jtlapp closed 2 years ago

jtlapp commented 2 years ago

Is there a way to get sveltestrap to recognize the use of local CSS selectors?

For example, I have this in my HTML and CSS:

<Col class="title">{title}</Col>
  .title {
    margin-bottom: 1em;
    font-weight: bold;
  }

But Svelte gives me an "Unused CSS selector" warning.

Do I need to disable this warning to use sveltestrap?

bestguy commented 2 years ago

This is a svelte limitation unfortunately, not specific to sveltestrap. Svelte does not recognize scoped classes on custom components, only Dom elements like div, input, etc.

You could use this selector:

:global(.title) {
  ...
}

which adds global css for your class added

jtlapp commented 2 years ago

Ah, I should have figured that out for myself. Thank you!