Answer the question
In order to leave comments, you need to log in
How to style a React component?
There is a component Button
, it has its own styles. But depending on where the , itself is Button
, it may have margins or other properties to fit inside the parent box.
Code for Button
export default class Button extends PureComponent {
render() {
return <button className="button">
<span className="button_text">
{this.props.children}
</span>
</button>
}
}
<Button className="popup_button">Отправить</Button>
<div className="popup_button">
<Button>Узнать больше</Button>
</div>
Answer the question
In order to leave comments, you need to log in
Inside the component, your passed class can be accessed in the same way as regular props, i.e. this.props.className.
Then everything is simple, a little check and addition of strings is enough to get the desired result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question