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

Adding Classes to elements result in "unused css selector" with in document CSS. #589

Open
littlefreak3000 opened this issue May 28, 2024 · 1 comment

Comments

@littlefreak3000
Copy link

littlefreak3000 commented May 28, 2024

<Row class="h-100">
   <Col class="left h-100">
   </Col>
   <Col class="right h-100">
   </Col>
</Row>

<Style>
.left {
   background: red;
}
.right {
   background: blue;
}
</Style>

Given the code above .left and .right css are not exported as svelte thinks they are unused.

@RoryDuncan
Copy link

This is actually a weakness in svelte—it doesn't trace through to "see" the component's prop corresponds to an eventual classname.

You can work around it via the :global selector.

Or, if it is something that scoping is very important, IIRC you can locally scope a class that has a child :global selector:

<div class="this”>
   <SomeComponent class="left" />
</div>

<style>

.this :global(.left) {
  ...
}
</style>

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

2 participants