Best practice for styling child components depending on the parent component

Viewed 61

I would like to know what is the best way to style child components depending on its parent component. For example, I want to create a list component to be used in a dropdown popup as well as in a toolbar. Depending on which parent component it is in, it is styled differently.

For me there are various ways to solve this. But I don't know the best practice for enterprise applications.

1 Answers

I can recommend you two ways first way You could add different css data for your component like this

enter image description here

the folder structure is always them/components/"your component name" and then you need to import your css data into global.scss enter image description here the second way is and I don,t recommend you this that you write all css styles of your components in the page which you use your components inside this enter image description here

Related