Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import Antd single component without messing up with the global style

I'd like to import a few components from the Ant Design React CSS library but I can't manage to get it working. I want to be able to import a single component without it messing up with the rest of my CSS.

Here's what I've tried:

import Button from 'antd/lib/button';
import 'antd/lib/button/style'; 

===> does not import the style.

import Button from 'antd/lib/button';
import 'antd/lib/button/style/css';

===> works, but messes up with the rest of the App

I have tried to do what is written here, import AntD on demand:

===> does not work, does not import the style

My question: is there a step-by-step guide to do what I want?

I'm not the only one who wants to do that and has problems, here, a guy on Reddit, I found many others links and have tried every single thing, absolutely nothing worked.

Thanks!

like image 434
mokiliii Lo Avatar asked Jan 17 '19 10:01

mokiliii Lo


Video Answer


1 Answers

import {Button} from 'antd'
import 'antd/lib/button/style';

worked for me...

what do you mean by

'===> does not import the style.`

???

like image 195
U.Rush Avatar answered Oct 29 '22 07:10

U.Rush