How to manage styling using JS in React? - reactjs

We are developing an application in React which has components like Input, Select, Accordion etc which can be re-used in a lot of other projects in our organisation to maintain a consistency.
We are using Material-UI styles to style our components using Javascript rather than CSS so that when other developers reuse the components they don't override the existing styling with CSS.
However, we have realised that the build time is long and when the components will be re-used in all the other projects,they will have a dependency on Material-UI which we don't want.
Can you guys please suggest on what is the best approach to maintain such application which can be re-used elsewhere and the best way to maintain the styles?

Related

How to use MUI inside CMS library?

We are currently using React Material UI for a big e-commerce site that requires a CMS.
The problem is that we need to give the elements in the CMS (that are configurable as pure HTML containers) the ability to use the same component animation and style as what we used in the MUI configuration in react.
Is there any way we can achieve this?
In other words, how can we create a html library from React Material UI?

Can I use bit-src to collect components from different React's UI framework

I need to make a bit-src place that hold my React components from different React UI framework, so I found that bit can make it easy, however how can I push React UI's components from many React UI into bit.into bit-src
(disclaimer - I help maintain Bit) You can export components from various projects to the same collection, thus creating your curated collection of components you use in your projects.
Each component can have its own build/test process. Components are completely detached from each other in regards to their build processes. So you can have components from different frameworks in the same collection.
Organizing the collection is something you control. Do whatever fit your needs.

Integration Material-UI with third-party react components

Is there any recomended way how to style third-party components such as react-paginate
with Material-UI primitives (bars, buttons)?
Is it possible at all?
One of the best ways to do this today is use styled-components. These allow you to pass in any 3rd party component and style them to your needs. Here is any example of how to do this with antd. Would be similar for you, except using Material UI components.

What is the CSS API?

Noob Question: Is the intention of the cSS API to make it possible to use the components as normal HTML without the need for any additional React code? Does the usage of only the CSS API therefore require the inclusion of the React JS package or can the Blueprint JS package alone work ?
As an author of Blueprint, I can confirm that it is in fact possible to use some of the Blueprint components via CSS only. Components that describe a CSS API in the documentation can be used without React, but usually with caveats (the biggest being that you must write the markup correctly). The CSS API is presented as an alternative to the JavaScript (React) API, and CSS modifiers are supported by the JS APIs through the className prop.
As Blueprint is a React-based UI toolkit, the best experience will be had by using React, primarily because you no longer have to write the markup correctly.
It is not possible to use the components as normal HTML, without ReactJS. Blueprint is a ReactJS UI toolkit for the web.
Their pre-made (React) components are customizable via a JavaScript API or a CSS API (or both).
The idea behind the CSS API, that some of the components have, is to provide additional options for style customization.
Let's use an example. See the Menu component. Its CSS API allows us to modify Menu's style. One example is that we can add icons to menu items, read in their docs:
Add icons to menu items the same way you would to buttons: simply add the appropriate pt-icon-<name> class*.
PS: I'd recommend you to head over the ReactJS docs, understand how ReactJS components work, get deeper knowledge about the core ReactJS concepts (or complete a fundamentals course) and only then - try to implement BlueprintJS.

Material-ui compatibility with other non-mui react components

Can I combine material-ui components with non-mui components without problems ? Are they compatible ?
If not, why not ?
In general there are no obstacles to use in one app bouth Material-UI and other Components. The only thing you need to take in mind that mui components need to be wrapped into MuiThemeProvider, so you need to organize your app structure to cover them all.
An additional issue may occur if you're going to create the themable app. You'll find that your non-mui components don't follow theme colors. In that case you can try to use react-theme-provider which solves common issues about it.
Usually ui components can work pretty well together. I know that some material ui component werent composable you had to pass props to customize them instead of putting component as childs but they have been working on that and you can customize with your own components more and more.

Resources