Answer the question
In order to leave comments, you need to log in
How to apply custom styles to react components?
Project - CRA + css-modules.
Let's say I have a component with my own styles. I want to import this button into another component. And I need to apply custom styles for correct positioning, for example, `margin` or `padding`. What is the best approach in such cases? The only thing that comes to mind is to pass them with props as inline styles.
Answer the question
In order to leave comments, you need to log in
Yes, this is how it is done, a button component is created that has default styles and can accept styles through props. If there are styles in the props, they are written inline. You can see how this is implemented, for example, in the react-bootstrap library
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question