admin管理员组文章数量:1323707
I am designing a web page with gatsby and I would like to use material UI, but I don't know which plugin to use.
My questions are :
- Is there a difference between those two, and how can I implement them in order to have a Theme Customized ?
- Where should I put the
theme.js
and where to put theThemeProvider
wrapper ? - How to configure the project ?
I am designing a web page with gatsby and I would like to use material UI, but I don't know which plugin to use.
My questions are :
- Is there a difference between those two, and how can I implement them in order to have a Theme Customized ?
- Where should I put the
theme.js
and where to put theThemeProvider
wrapper ? - How to configure the project ?
1 Answer
Reset to default 12Both packages do the trick: Get Material UI into your project.
The difference is that gatsby-theme-material-ui
is more plete and user-friendly for beginners. For example with the plugin
, you have to make sure you load the roboto font or the MUI theme
yourself. The theme
sets everything you need for Material UI up for you and you can start developing right away.
All the plugin
does is to make sure the Material UI styles are properly loaded into your project. This is important because of how Gatsby works with server-side rendering. This can be tricky to get right and understand when starting out. But you still have to get your fonts and the theme provider setup as explained in the docs.
There is a technical parison what each plugin does:
Theme vs. Plugin
- gatsby-plugin-material-ui solves FOUC, auto prefixing and minification.
- gatsby-theme-material-ui uses the plugin under the hood, adds web fonts, meta-viewport, CSS baseline and mui theme support and has material ui styled gatsby link ponents
For new users I would remend gatsby-theme-material-ui
how can I implement them in order to have a Theme Customized
Follow the documentation. Create the file src/gatsby-theme-material-ui-top-layout/theme.js
and use this file to customize your theme as described in the MUI docs.
Where should I put the theme.js and where to put the ThemeProvider wrapper
Follow the documentation. Create a provider in src/gatsby-theme-material-ui-top-layout/ponents/top-layout.js
.
And also how to configure the project
Follow the documentation.
// with npm
npm install gatsby-theme-material-ui @material-ui/core
// with yarn
yarn add gatsby-theme-material-ui @material-ui/core
Edit gatsby-config.js
module.exports = {
plugins: [
// ... other plugins
`gatsby-theme-material-ui`
],
};
Your Gatsby configuration is done.
本文标签: javascriptDifference between gatsbythemematerialui and gatsbypluginmaterialuiStack Overflow
版权声明:本文标题:javascript - Difference between gatsby-theme-material-ui and gatsby-plugin-material-ui - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742130664a2422143.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论