I'm using Ant Design in my react project. I wanna use Ant Design components without their default class names.
Pay attention to the following code:
import { Typography } from "antd";
const { Title } = Typography;
~~
<Title level={4}> ...
Causes to have below:
<h4 class="ant-typography" ...
And its CSS:
// in the less file:
h4.ant-typography {
// some css
}
So when I add my class name to the component the priority of the class name of Ant Design component is higher than mine!
My class name is .root-23-07
. this priority number is 10
but because of using tag name in less file the priority number of And Design CSS selection is 11
. so the Ant Design styles override mine.
I wanna use components of And Design without default class names. Is it possible?
If I understand your question correctly, no, you cannot use antd without having the underlying class names. Because React outputs raw html and css, not having the class names would result in not having any styling outside the css you provide.
You will either need to make your classes match the specificity level, or use !important
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments