How to import Ant Design components without default class names?

user8106148

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?

Matthew Weeks

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to import Ant Design css styles in GlobalStyles of styled-components.?

How to add custom components into Ant Design stepper?

How to use ant-design-pro components in ant-design react app?

How to render default value in ant design checkbox using boolean?

How to validate ant design formitems without using getFieldDecorator in reactjs?

How to import a class from default package

Using Ant Design Variables in Styled Components

Vue: How does vuetify make its components available without import?

How to import directives without repeatedly writing to some components

Snowpack with Ant Design: Import "antd" could not be resolved

React Router with - Ant Design Sider: how to populate content section with components for relevant menu item

Passing in class names to react components

React | Ant design select default value

How to fill default values based on column names without typeerror - Pandas

How to import properties in a class from a list of property names?

How to use default bootstrap class with styled-components?

How to find the default css class name of React components?

How it is possible to import express from 'express' without a default export?

How to Import Dataset without header and names separate files in R and attach the names to dataset?

How to customize Component of Ant Design?

How do I import servlet class in jsp when package is default?

Change behavior of Steps React component from Ant Design(https://ant.design/components/steps/)

How to parse JSON data without key names into a Java class structure?

How to get all method names of a class without inherited methods with Groovy?

How would you design a function that attaches children of a Component class to an Object class if the components can hold different data?

Vue.js/NuxtJS - how to create components with a default design customizable by a JSON configuration file

Mapbox in React without Class Components

How to import class using ES6 syntax? (without Babel)

Add empty unused class names to react components