I'm building one (own) Material-UI project which I can import whenever I create a new project. So this project only has material-ui and react (react as a peer dependency). I am able to import most of the material-ui components, but how can I have my own default theme file (Default MuiTheme)?
So, the react project which will import this custom material-ui project and have those default styles from default theme. But, if I want to customize, i should be able to override the mui theme.
You can create a mytheme.js file with custom theme and wrap your app in the ThemeProvder component to make it available for the entire app.
Here are the documentation links to the theme variables that you can use to customize
https://material-ui.com/customization/default-theme/#default-theme
https://material-ui.com/customization/theming/#theme-provider
Example: https://stackblitz.com/edit/esmns5-s5ft8h?file=demo.js
<ThemeProvider theme = {mytheme}>
<App/>
</ThemeProvider>
Related
I have a custom TinyMCE plugin that add a toolbar icon to the tinymce tool bar. Plugin is configured in a file called editor_plugin.js which is placed inside my custom EpiServer module. I need this to register in tinyMCE.
I added following code in the startup.cs file:
services.Configure<TinyMceConfiguration>(config =>
{
config.Default()
.AddEpiserverSupport()
.AddExternalPlugin("qbankmodule", "/QbankModule/TinyPlugin/editor_plugin.js")
.AppendToolbar("qbankmodule");
});
but I am getting following error in TinyMCE toolbar area:
Failed to load plugin url: http://localhost:8000/EPiServer/EPiServer.Cms.TinyMce/3.1.0/ClientResources/tinymce/QbankModule/TinyPlugin/editor_plugin.js
I Have following questions:
How can I point this to the editor_plugin.js file in the QbankModule I have it as QbankModule/TinyMCE/editor_plugin.js but now it is loading from EPiServer.Cms.TinyMce module.
Instead of registering this in the startup.cs since our product it this QbankModule, we need this to be registered using Customized TinyMce Initialization module using IConfigurableModule. Any one have experience in this area how to implement that?
If I used both of them, could I run into conflicts? Is this a good approach to use?
It is possible and the MUI team has been resolved it.
From the documentation:
If you are used to Tailwind CSS and want to use it together with the MUI components, you can start by cloning the Tailwind CSS example project. If you use a different framework or already have set up your project.
It is necessary to Remove Tailwind's base directive in favor of the CssBaseline component provided by #mui/material and fix the CSS injection order.
You can read how: https://mui.com/guides/interoperability/#tailwind-css
Yes you can run both ui framework. But it is not a good approach. Every ui framework has the complete solution for designing ui part. Like in tailwind css you can have the JIT compiler for compilation your custom css. Or the other hand MUI has also.
I think you can go through just only on ui framework. I have suggestion for ui. For your next js project you can use-
Tailwind Css
Theme-ui
Thank you.
Definitely, You will be in a big problem because once you initialize a styling library it applies its basic styles to the components so that if you are using more than one styling library you may not be able to change the behavior or styles of the components.
It also leads to rubbish suggestions while adding classes names and so on.
Stick to a UI libray and go with it.If you cant get it using the ui libraray do it yourself using CSS that could be more interesting and you can have more control over the components.
Use Mui base instead of Mui core.
https://mui.com/base/guides/working-with-tailwind-css/
I have tried using Mui and Tailwindcss together and it's not worth it. First, you will have to use Mui/base instead of Mui/material in order to reduce conflicts check https://mui.com/base/guides/working-with-tailwind-css. And if you really need to customize Mui components styled of the sx prop. This is just my opinion.
I'm trying import css just like I do normally in react.
import "#styles/my_lovely_component.sass"
It obviously shows the error that I cannot import global styles in components. If I change the name from my_lovely_component.sass to my_lovely_component.module.sass, the error is suppressed but the styles aren't really applied/included on my page or components.
I found out people use component styles like this
import styles from "#styles/my_lovely_component.module.sass"
const JustAComponent = () => <img className={styles.doggo_img} />
This gets annoying very quickly. I literally have been working by importing all styles globally in __app.ts, because I couldn't find a working solution to import styles like the good old(well not really old) way.
Any help will be appreciated. Thanks.
(I did consider the other styling methods like styled-jsx/components, emotion and stuff. But they're even more annoying.)
If you want to add global styles for your next project
At first you need loader in next-config.js
then read about _document.js where you can add global styles to the head.
I am having an issue with Liferay 7 Themes and AUI. First, it is my understanding each Liferay page is divided into sections, as defined here:
- https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/6-2/setting-up-custom-css
And I must wrap any custom css with the appropriate wrapper, as defined in the above link. Any css defined in the theme applies to the appropriate section of the page, for all pages in the web application. I can also create custom wrappers within the theme, which individual portlets may reference using the 'com.liferay.portlet.css-class-wrapper' annotation.
I can therefore change the AUI Button's appearance by creating a css class and referring to it as follows:
< aui:button cssClass="btn-lg".../>
But it is less clear to me how I can apply custom css to AUI Data tables. Guidance is certainly appreciated.
You can use theme contributors.
And there create a .scss file and put customized styles for datatable there like :
.yui3-datatable{
& thead{
backgournd-color: red;
}
}
You can also use 'your-theme/css/custom.csss' to override default style with your custom styles.
I have made my own custom theme.
As i set this theme in zk.xml
<library-property>
<name>org.zkoss.theme.preferred</name>
<value>MYTheme</value>
</library-property>
the theme is being applied ,but as i will be creating My own multiple custom themes how do i choose it programitacally?
The available methods and a way to customize the theme resolution are described in our documentation on Switching Themes.
You can change the default theme for all users at runtime by setting the library property (after reloading the page the theme is applied):
Library.setProperty("org.zkoss.theme.preferred", "custom");
Executions.sendRedirect("");
To switch the theme for an individual user the following method sets a cookie (by default):
Themes.setTheme(Executions.getCurrent(), "custom");
Executions.sendRedirect("");
Robert