I
I
Ildar Nogmanov2019-01-30 15:33:50
css
Ildar Nogmanov, 2019-01-30 15:33:50

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

2 answer(s)
A
Andrey Okhotnikov, 2019-01-30
@bibinur

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

D
davidnum95, 2019-01-30
@davidnum95

classnames

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question