Antd: prevent style override? - reactjs

In my tsx react project, I am using styled components and have created a few pages. Now I wanted to use a modal, so I tried using the antd modal. However, the antd styles have completely overridden my page's styles.
for instance, I have set the background and text fonts through styled components, and everything is running automatically. How do I prevent antd from applying it's background and text colors, and make it leave it as whatever it is?

Related

Change background of react app according to Chakra UI color mode

I am new to Chakra UI and React, and would like to to implement a background changing according to the color mode of Chakra(dark/light).
I have tried several versions, I could use any of them(there are no limitations), but none of them worked:
Dynamic SVG component as background - had positioning issues.
Trying to change SCSS variables with react on color mode change
Trying to read color mode from the cookies in SCSS as the chakra
ui color mode is stored in the cookies
have an inline styled component with useColorMode() hook - this is partially working, but only if I refresh the page(tried useEffect() and useMemo() as well but did not help)
So I basically fixed it with turning the background opacity of the SVG to 0, this way, the color mode of the page is visible.

Possible to inject material UI styles into iframe?

I'm using material UI 4.9.x and it doesn't seem possible to use MUI in an iframe with the global styles.
I'm trying to use a React portal to inject the content into the iframe.
THAT part works and my MUI context menu works properly, just has the wrong styles.
I'm trying to inject the styles via CssBaseline but that gets injected into the host window not the iframe window.
I've verified this by looking at the DOM and I can see the elements created there under and not in the iframe.
How would I go about injecting this, completely, into the iframe window.
One idea I had was to change the current / global document and window objects to represent the iframe but worried that might be too hacky.

Add a font face css in reactjs

fabricjs can change the font of a text in a canvas to a font family. For that the font needs to exist in the browser, either CSS or emb link.
I now want to add dynamically a font from a resource (google, self hosted ect) to the css populating it in the document via #font-face. I don't want to just list all fonts in the css beforehand because it can be a huge list. Is it possible to modify the running css in reactjs to add a font face to it?
Use CSS-in-JS solutions like emotion, styled component or radium

styling `TextValidator` in react-material-ui-form-validator

I am using react-material-ui-form-validator in my react form for material design as well as for validation, now i want to change the color of shrink label but not able to find any option to styling TextValidator, React material provide option to add class when label is shrink but not this. Any idea how I can use material design with the easy validation in react
this is the package that I am using
https://github.com/NewOldMax/react-material-ui-form-validator
I have resolved it by applying styling with the data-attribute

Dynamically import SASS files via React

I have to make interface suitable with two different color themes - light and dark. Color theme is being selected by user via button/switch/whatever.
The problem (as I think) is that my React application is being bundled via Webpack, so all my SASS-compiled styles is being embedded into the main HTML template as <style>...</style> (each style tag references to its SASS-file). I know, that I can assign some class name to app wrapper and then write nested style for every selector that needs to be recolorized. But it is not such productive as, for example, import necessary SASS file depending on what color theme was selected by user.
Is there any way to solve this problem in a better way?

Resources