Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/material-components/material-components-web-react
Material Components for React (MDC React)
https://github.com/material-components/material-components-web-react
material-components react
Last synced: 8 days ago
JSON representation
Material Components for React (MDC React)
- Host: GitHub
- URL: https://github.com/material-components/material-components-web-react
- Owner: material-components
- License: mit
- Created: 2018-03-06T19:42:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-11T01:41:10.000Z (26 days ago)
- Last Synced: 2024-10-28T06:31:07.553Z (9 days ago)
- Topics: material-components, react
- Language: TypeScript
- Homepage:
- Size: 6.77 MB
- Stars: 2,018
- Watchers: 64
- Forks: 227
- Open Issues: 221
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Roadmap: ROADMAP.md
Awesome Lists containing this project
- awesome-material-design - React Material Components - Port fo Material Components for the Web to react (React / Frameworks)
- awesome-material-components - material-components/material-components-web-react - React.js wrapper by Material Components team. (Material Components Web (MDC Web) / MDC Web Framework Integrations)
README
[![Build Status](https://api.travis-ci.com/material-components/material-components-web-react.svg?branch=master)](https://travis-ci.com/material-components/material-components-web-react/)
[![codecov](https://codecov.io/gh/material-components/material-components-web-react/branch/master/graph/badge.svg)](https://codecov.io/gh/material-components/material-components-web-react)
[![Chat](https://img.shields.io/discord/259087343246508035.svg)](https://discord.gg/material-components)# Material Components for React (MDC React)
> NOTE: MDC-React is no longer under active development
> We created MDC-React in 2018 to implement the updated Material Design guidelines. Since then, the open-source React community has embraced the new guidelines and created a number of excellent unofficial implementations. See [Material Design Components - Web Framework Wrappers](https://github.com/material-components/material-components-web/blob/master/docs/framework-wrappers.md) for a partial list.
> In order to increase our focus on implementing our core, framework-independent libraries ([MDC-Web](https://github.com/material-components/material-components-web) and [MWC](https://github.com/material-components/material-components-web-components)), we’re passing the Material+React baton back to the community. That means Material Design will no longer be updating and maintaining this repo. We recommend that you switch to another implementation and keep building beautiful, usable apps based on Material Design. Thanks for being part of the project!
MDC React was an official implementation of Google's Material Design components for React. It is a wrapper library for [MDC Web](https://github.com/material-components/material-components-web). Please refer to our [MDC Web Catalog](https://material-components.github.io/material-components-web-catalog/#/) to play and interact with the Components.
![mpmgq9h6b9x](https://user-images.githubusercontent.com/579873/44939654-d8fdfd80-ad3b-11e8-9b64-6244cb5e6886.png)
## Components
The following is a list of the components that are ready to be used, with corresponding links to the [material.io](https://material.io/) design spec and [MDC Web code](https://github.com/material-components/material-components-web).
Component | Spec | MDC Web
---- | ---- | ----
[Button](./packages/button) | [Button Design Page](https://material.io/design/components/buttons.html) | [MDC Button](https://github.com/material-components/material-components-web/tree/master/packages/mdc-button)
[Card](./packages/card) | [Card Design Page](https://material.io/design/components/cards.html) | [MDC Card](https://github.com/material-components/material-components-web/tree/master/packages/mdc-card)
[Checkbox](./packages/checkbox) | [Checkbox Design Page](https://material.io/design/components/selection-controls.html#checkboxes) | [MDC Checkbox](https://github.com/material-components/material-components-web/tree/master/packages/mdc-checkbox)
[Chips](./packages/chips) | [Chips Design Page](https://material.io/design/components/chips.html) | [MDC Chips](https://github.com/material-components/material-components-web/tree/master/packages/mdc-chips)
[Dialog](./packages/dialog) | [Dialog Design Page](https://material.io/design/components/dialogs.html) | [MDC Dialog](https://github.com/material-components/material-components-web/tree/master/packages/mdc-dialog)
[Drawer](./packages/drawer) | [Drawer Design Page](https://material.io/design/components/navigation-drawer.html) | [MDC Drawer](https://github.com/material-components/material-components-web/tree/master/packages/mdc-drawer)
[Fab](./packages/fab) | [Fab Design Page](https://material.io/design/components/buttons-floating-action-button.html) | [MDC Fab](https://github.com/material-components/material-components-web/tree/master/packages/mdc-fab)
[Floating Label](./packages/floating-label) | [Text Field Design Page](https://material.io/design/components/text-fields.html) | [MDC Floating Label](https://github.com/material-components/material-components-web/tree/master/packages/mdc-floating-label)
[Icon Button](./packages/icon-button) | [Icon Button Design Page](https://material.io/design/components/buttons.html#toggle-button) | [MDC Icon Button](https://github.com/material-components/material-components-web/tree/latest-release/packages/mdc-icon-button)
[Layout Grid](./packages/layout-grid) | [Layout Grid Design Page](https://material.io/design/layout/responsive-layout-grid.html#responsive-ui-grid) | [MDC Layout Grid](https://github.com/material-components/material-components-web/tree/latest-release/packages/mdc-layout-grid)
[Line Ripple](./packages/line-ripple) | [Text Field Design Page](https://material.io/design/components/text-fields.html) | [MDC Line Ripple](https://github.com/material-components/material-components-web/tree/master/packages/mdc-line-ripple)
[Linear Progress](./packages/linear-progress) | [Linear Progress Design Page](https://material.io/design/components/progress-indicators.html) | [MDC Linear Progress](https://github.com/material-components/material-components-web/tree/master/packages/mdc-linear-progress)
[List](./packages/list) | [List Design Page](https://material.io/design/components/lists.html) | [MDC List](https://github.com/material-components/material-components-web/tree/latest-release/packages/mdc-list)
[Material Icon](./packages/material-icon) | [Material Icon Design Page](https://material.io/design/iconography/system-icons.html#design-principles) | [Material Icon Tool](https://material.io/tools/icons/?style=baseline)
[Menu Surface](./packages/menu-surface) | [Menu Surface Design Page](https://material.io/design/components/menus.html#design-principles) | [MDC Menu Surface](https://github.com/material-components/material-components-web/tree/master/packages/mdc-menu-surface)
[Menu](./packages/menu) | [Menu Design Page](https://material.io/design/components/menus.html#design-principles) | [MDC Menu](https://github.com/material-components/material-components-web/tree/master/packages/mdc-menu)
[Notched Outline](./packages/notched-outline) | [Text Field Design Page](https://material.io/design/components/text-fields.html) | [MDC Notched Outline](https://github.com/material-components/material-components-web/tree/master/packages/mdc-notched-outline)
[Radio](./packages/radio) | [Radio Design Page](https://material.io/design/components/selection-controls.html#radio-buttons) | [MDC Radio](https://github.com/material-components/material-components-web/tree/master/packages/mdc-radio)
[Ripple](./packages/ripple) | [Ripple Design Page](https://material.io/design/interaction/states.html) | [MDC Ripple](https://github.com/material-components/material-components-web/tree/master/packages/mdc-ripple)
[Select](./packages/select) | [Select Design Page](https://material.io/design/components/menus.html#) | [MDC Select](https://github.com/material-components/material-components-web/tree/master/packages/mdc-select)
[Snackbar](./packages/snackbar) | [Snackbar Design Page](https://material.io/design/components/snackbars.html) | [MDC Snackbar](https://github.com/material-components/material-components-web/tree/master/packages/mdc-snackbar)
[Switch](./packages/switch) | [Switch Design Page](https://material.io/design/components/selection-controls.html#switches) | [MDC Switch](https://github.com/material-components/material-components-web/tree/master/packages/mdc-switch)
[Tab](./packages/tab) | [Tabs Design Page](https://material.io/design/components/tabs.html) | [MDC Tab](https://github.com/material-components/material-components-web/tree/master/packages/mdc-tab)
[Tab Bar](./packages/tab-bar) | [Tabs Design Page](https://material.io/design/components/tabs.html) | [MDC Tab Bar](https://github.com/material-components/material-components-web/tree/master/packages/mdc-tab-bar)
[Tab Indicator](./packages/tab-indicator) | [Tabs Design Page](https://material.io/design/components/tabs.html) | [MDC Tab Indicator](https://github.com/material-components/material-components-web/tree/master/packages/mdc-tab-indicator)
[Tab Scroller](./packages/tab-scroller) | [Tabs Design Page](https://material.io/design/components/tabs.html) | [MDC Tab Scroller](https://github.com/material-components/material-components-web/tree/master/packages/mdc-tab-scroller)
[Text Field](./packages/text-field) | [Text Field Design Page](https://material.io/design/components/text-fields.html) | [MDC Text Field](https://github.com/material-components/material-components-web/tree/master/packages/mdc-textfield)
[Top App Bar](./packages/top-app-bar) | [Top App Bar Design Page](https://material.io/design/components/app-bars-top.html) | [MDC Top App Bar](https://github.com/material-components/material-components-web/tree/master/packages/mdc-top-app-bar)
[Typography](./packages/typography) | [Typography Design Page](https://material.io/design/typography/the-type-system.html#type-scale.html) | [MDC Typography](https://github.com/material-components/material-components-web/tree/master/packages/mdc-typography)## Getting Started
### With StackBlitz
If you're looking to see how it looks without having to install a bunch of npm modules in your environment, please have a look at this [Starter Stackblitz](https://stackblitz.com/edit/react-eeyij6).
### With create-react-app
`create-react-app` is a popular CLI tool to getting started with React. If you're new to React or Webpack, you might be starting out here. This section will walk you through configuring `create-react-app` to install and use our components.
If you're using an older version (v1) of `create-react-app`, please refer to our [create-react-app-v1 doc](docs/create-react-app-v1.md).
> Recommended things to know
> 1. node/npm
> 2. JavaScript
> 3. HTML/CSS
> 4. ES6> _NOTE:_ If you haven't used `create-react-app` before, you may want to read the [Overview Guide](https://github.com/facebook/create-react-app#quick-overview).
#### Step 1: Install create-react-app
> _NOTE:_ all npm commands can be replaced with yarn
Install `create-react-app`:
```
npx create-react-app my-app
cd my-app
npm start
```##### Use with Typescript
It is recommended to use Typescript with our components. You will need to add a few more modules for this to work"
```
npm i @types/react @types/react-dom @types/classnames @types/node typescript
npm start
```#### Step 2: Install Components
Install Button:
```
npm install @material/react-button
```#### Step 3: Using Sass
If you want to use the compiled CSS and not customize any colors, text, etc. you can skip to [Step 3a](#step-3a-use-compiled-css).
Most likely you'll want to start using the [Sass mixins](https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md#sass) to customize your app. MDC Sass files are not supported out of the box, since we do not prepend `~` to our module imports. See this [Github issue](https://github.com/facebook/create-react-app/issues/4494#issuecomment-428531848) explaining the issue in detail. There is a workaround, but requires some work on your end (we promise it is not too difficult).
##### Add environment variable
To get MDC React Components to work with `create-react-app` you need to set a `SASS_PATH` environment variable that points to your `node_modules` directory. To quickly do this on OS X or Linux enter the following in your command line:
```sh
export SASS_PATH=./node_modules
```If you're on Windows use the following:
```bat
SET SASS_PATH=.\node_modules
```Rename your `src/App.css` file to `src/App.scss`. You will also need to install `node-sass`:
```sh
npm install node-sass
```If you permanently want to add this to your environment, read [adding environment variables](./docs/adding-env-variables.md). You're now ready to start using MDC React Sass modules in your `create-react-app`.
> _NOTE:_ this assumes that you will run `npm start` (or `yarn start`) from the root directory. By default this is how create-react-app is setup.
```sass
// ./src/App.scss@import "@material/react-button/index.scss";
@import "./react-button-overrides";...
``````sass
// ./react-button-overrides.scss@import "@material/button/mixins";
.button-alternate {
@include mdc-button-container-fill-color(lightblue);
}```
#### Step 3a: Use Compiled CSS
If you performed [Step 3](#step-3-using-sass), then you can skip to [Step 4](#step-4-use-mdc-react-button).
If you don't need to customize your app, then using the CSS is a quicker way to get started with MDC React Components. Each package comes with a `/dist` directory, which includes the CSS files compiled from our Sass files. `create-react-app` is ready to import CSS files. To import the Button CSS copy the following line into `./src/App.js` imports:
```js
import '@material/react-button/dist/button.css';
```If you want to use the minified version, the import instead looks like:
```js
import '@material/react-button/dist/button.min.css';
```#### Step 4: Use MDC React Button
Open `./src/App.js`. Then replace the boilerplate App code (entire file) with the barebones MDC React Button:
```js
import React, {Component} from 'react';
import Button from '@material/react-button';import './App.scss';
// add the appropriate line(s) in Step 3a if you are using compiled CSS instead.class App extends Component {
render() {
return (
console.log('clicked!')}
>
Click Me!
);
}
}export default App;
```You can also use these same configurations for your own Webpack build pipeline without `create-react-app`. But this is the quickest way to getting started with MDC React Components. Button is one of our simpler components, but you should be able to apply these same principles you learn here to any the components. Thanks for trying out MDC React Components, and remember to tell a friend! Enjoy!
## Need help
We're constantly trying to improve our components. If Github Issues don't fit your needs, then please visit us on our [Discord Channel](https://discord.gg/material-components).