Difference between gatsby-theme-material-ui and gatsby-plugin-material-ui
Answer a question
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.jsand where to put theThemeProviderwrapper ? - How to configure the project ?
Answers
Both packages do the trick: Get Material UI into your project.
The difference is that gatsby-theme-material-ui is more complete 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 comparison 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 components
For new users I would recommend 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/components/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.
更多推荐
所有评论(0)