12

Material-UI is a very big package and I only want to use one component of it.

Is there a way to install a package that only contains the component I want to use?

e.g.

use

import Button from '@material-ui/core/Button';

But only have in your package.json something like @material-ui/core/Button.

The reason I want this is to have a small node_modules.

Vencovsky
  • 28,550
  • 17
  • 109
  • 176

4 Answers4

9

you can install each component of Material-UI via bit.dev collection:
https://bit.dev/mui-org/material-ui
Here is the Button component for example:
https://bit.dev/mui-org/material-ui/button

I exported the project to bit.dev and I'm trying to keep it up to date as much as possible.

Josh
  • 670
  • 7
  • 14
  • 4
    Is it still working? I tried to install some packages but none works – agentp Nov 10 '21 at 15:20
  • Is it free? I can't figure it out and when I try to sign up I get an error. When I try to install I get a 404 so I guess it no longer maintained. – Mote Zart Feb 18 '22 at 14:56
2

You can install and use the isolated material components here: bit.dev

Ali Torki
  • 1,929
  • 16
  • 26
1

Unfortunately, you can't install the separate components from the Material UI. The only way is to install the @material-ui/core directly.

1

You don't need to care about the size of the node_modules folder. "The bundle size will NOT increase if you install the entire MUI package but just import one single component.

In fact, I can install every single node modules in npm without using a single import statement and my bundle size will not magically become gigantic."

Do you actually care about the size of node_modules?

Nam Lee
  • 891
  • 1
  • 9
  • 20