Dominik Domanski
Dominik Domanski

Reputation: 1033

How can I pass scss file to a react component as props?

I have a component which I use all over my application, but it's style may somehow differ. Before I did not reuse this component, and was able to import scss file, knowing a path to it. Now I want to make it reusable and want to make it aware of styles that go in scss file, is there a nice way to do that?

Upvotes: 0

Views: 777

Answers (1)

keul
keul

Reputation: 7819

If I understand what you are asking: you can't do that.

That's because the import 'xxx.scss' is performed offline, at the time you build your application and the bundler (webpack, or whatever you are using) will parse SCSS and transform it to static or inline css.

So you can't distribute a component that read a SCSS file from a prop. Try to look at something like a theme provider.

Upvotes: 1

Related Questions