Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between gatsby-theme-material-ui and gatsby-plugin-material-ui

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 ?
like image 789
Andres Xavier Vargas Vera Avatar asked May 31 '20 04:05

Andres Xavier Vargas Vera


People also ask

What is a theme material UI?

The theme specifies the color of the components, darkness of the surfaces, level of shadow, appropriate opacity of ink elements, etc. Themes let you apply a consistent tone to your app. It allows you to customize all design aspects of your project in order to meet the specific needs of your business or brand.

Can you use material UI with Gatsby?

Material-UI is a React UI framework that implements Google's Material Design principles in React. It can be added to Gatsby projects in a variety of ways and we'll see how to use it simply with a plugin.

What is Gatsby UI?

It allows you to style any component in your application with typographic, color, and layout values defined in a shared theme object. Theme UI is currently used in Gatsby's official themes, but it can be used in any Gatsby site or React application.


1 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.

like image 92
EliteRaceElephant Avatar answered Oct 23 '22 05:10

EliteRaceElephant