Load CSS for Certain Route

Is there a way to load a css file, and subsequently unload a css file when a route loads?

From my experience, no.

The thing you could do is either use inline CSS (super easy and simple with React) or create unique classes or classNames for the pages that need custom CSS.

I thought, for some reason, that the import directory would accomplish this.

What we do is add a link tag to header with an id then remove it when we are done.

1 Like

I had tried that, I just wasn’t sure if there was an easier method.

One other thing that I tried and seemed to work, is put a wrapper element in the template file and then use nesting scss styles so they’re applied selectively to the individual templates. I don’t think this is an issue.

Curious, where do you place your css files in this case? Public?

Right, in public, using cloudfront to mirror.