admin管理员组

文章数量:1323529

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 the ThemeProvider 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 the ThemeProvider wrapper ?
  • How to configure the project ?
Share Improve this question edited May 31, 2020 at 5:06 Littm 4,9474 gold badges33 silver badges39 bronze badges asked May 31, 2020 at 4:15 Andres Xavier Vargas VeraAndres Xavier Vargas Vera 831 silver badge5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 12

Both 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