material ui
In the ground since Mon May 06 2024
Last watered inMon May 06 2024
Related Topics
Material UI
Material UI is an open-source React component library that implements Google's Material Design.
It includes a comprehensive collection of prebuilt components that are ready for use in production right out of the box, and features a suite of customization options that make it easy to implement your own custom design system on top of our components.
Material UI x Base UI
Material UI and Base UI feature many of the same UI components, but Base UI comes without any default styles or styling solutions.
Base UI, by contrast, could be considered the "skeletal" or "headless" counterpart to Material UI—in fact, future versions of Material UI will use Base UI components and hooks for its foundational structure.
Setup
Quick Intro
- React and React DOM are peer dependencies
- Material UI uses Emotion as its default styling engine.
- But we can use with Styled Components
Installation
Usage
We can starting using MUIs Components right away But we wouldn't have the MUI's default Font working. It uses Roboto, the font-family is already set with the correct value, but we need to install the font:
- Install Roboto via NPM and bundle the font.
- Import Roboto via CDN e.g Google Fonts
Using via Google Fonts
Using via NPM Package
Then we can import it in our App TS/TSX
Now can already start coding UIs with Material UI! But, from now on, let's enhance our knowledge about MUI as much as possible. Let's start filling the real world needs of a Web App.
Breakpoints
- Create a theme and provide it to the App
- Customize the App's theme: It's very likely we'll need to target different screens sizes than the MUI's default values. We just need to chose if we're keeping the breakpoints abbreviations like "xs", "md" ..., or if we're going to use different words like "mobile", "tablet", "desktop".
In case there's no naming changing:
In case there is naming changing:
If we're using Typescript, we can extend the default theme; Let's set a global declaration file to hold all the extensions we need. Further, we can better organize the .d files:
tsconfig.json
global.d.ts
Custom Fonts
We'll like have to change the default font-family. We can do it setting it on the custom theme:
Icons
Via package
Via Google Fonts
"We do not recommend using this approach in production. It requires the client to download the entire library—regardless of which components are actually used—which negatively impacts performance and bandwidth utilization."