SolidJSS
SolidJSโ€ข2y agoโ€ข
7 replies
Parker Codes

Scope styles to a page

Heyo! I want to be able to scope some CSS to only apply when that page component is mounted. This CSS targets the html and body tags and is not for the component itself.

Currently I am doing import "./layout.css";, which correctly applies the styles when on this page, but then the styles remain in effect when I navigate to other pages.

I could use :has() but support isn't all the way there yet. I could utilize mount and cleanup, but not sure how I could "run" and dispose of the CSS because that's not how CSS works.
Was this page helpful?