I wrap existing component with styled-component but I find it annoying to have to declare !important
to overwrite the existing style of that component, for example
import { Row, Col, Card, Typography } from 'antd'
const { Title } = Typography
const StyledTitle = styled(Title)`
text-align: center;
margin: 50px 0 20px 0 !important;
font-weight: normal !important;
`
It's hard to see which property have to use important, I detect it via visual changes after I save the file, which is so annoying, what's the solution to this?
They recommend adding ampersands
const StyledTitle = styled(Title)`
&&& {
text-align: center;
margin: 50px 0 20px 0;
font-weight: normal;
}
`
https://styled-components.com/docs/faqs#how-can-i-override-styles-with-higher-specificity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With