Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

Material Components for React (MDC React)

License

NotificationsYou must be signed in to change notification settings

material-components/material-components-web-react

Repository files navigation

Build StatuscodecovChat

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. SeeMaterial Design Components - Web Framework Wrappers for a partial list.

In order to increase our focus on implementing our core, framework-independent libraries (MDC-Web andMWC), 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 forMDC Web. Please refer to ourMDC Web Catalog to play and interact with the Components.

mpmgq9h6b9x

Components

The following is a list of the components that are ready to be used, with corresponding links to thematerial.io design spec andMDC Web code.

ComponentSpecMDC Web
ButtonButton Design PageMDC Button
CardCard Design PageMDC Card
CheckboxCheckbox Design PageMDC Checkbox
ChipsChips Design PageMDC Chips
DialogDialog Design PageMDC Dialog
DrawerDrawer Design PageMDC Drawer
FabFab Design PageMDC Fab
Floating LabelText Field Design PageMDC Floating Label
Icon ButtonIcon Button Design PageMDC Icon Button
Layout GridLayout Grid Design PageMDC Layout Grid
Line RippleText Field Design PageMDC Line Ripple
Linear ProgressLinear Progress Design PageMDC Linear Progress
ListList Design PageMDC List
Material IconMaterial Icon Design PageMaterial Icon Tool
Menu SurfaceMenu Surface Design PageMDC Menu Surface
MenuMenu Design PageMDC Menu
Notched OutlineText Field Design PageMDC Notched Outline
RadioRadio Design PageMDC Radio
RippleRipple Design PageMDC Ripple
SelectSelect Design PageMDC Select
SnackbarSnackbar Design PageMDC Snackbar
SwitchSwitch Design PageMDC Switch
TabTabs Design PageMDC Tab
Tab BarTabs Design PageMDC Tab Bar
Tab IndicatorTabs Design PageMDC Tab Indicator
Tab ScrollerTabs Design PageMDC Tab Scroller
Text FieldText Field Design PageMDC Text Field
Top App BarTop App Bar Design PageMDC Top App Bar
TypographyTypography Design PageMDC 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 thisStarter Stackblitz.

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 configuringcreate-react-app to install and use our components.

If you're using an older version (v1) ofcreate-react-app, please refer to ourcreate-react-app-v1 doc.

Recommended things to know

  1. node/npm
  2. JavaScript
  3. HTML/CSS
  4. ES6

NOTE: If you haven't usedcreate-react-app before, you may want to read theOverview Guide.

Step 1: Install create-react-app

NOTE: all npm commands can be replaced with yarn

Installcreate-react-app:

npx create-react-app my-appcd my-appnpm 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 typescriptnpm 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 toStep 3a.

Most likely you'll want to start using theSass mixins to customize your app. MDC Sass files are not supported out of the box, since we do not prepend~ to our module imports. See thisGithub issue 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 withcreate-react-app you need to set aSASS_PATH environment variable that points to yournode_modules directory. To quickly do this on OS X or Linux enter the following in your command line:

export SASS_PATH=./node_modules

If you're on Windows use the following:

SETSASS_PATH=.\node_modules

Rename yoursrc/App.css file tosrc/App.scss. You will also need to installnode-sass:

npm install node-sass

If you permanently want to add this to your environment, readadding environment variables. You're now ready to start using MDC React Sass modules in yourcreate-react-app.

NOTE: this assumes that you will runnpm start (oryarn start) from the root directory. By default this is how create-react-app is setup.

// ./src/App.scss@import"@material/react-button/index.scss";@import"./react-button-overrides";...
// ./react-button-overrides.scss@import"@material/button/mixins";.button-alternate {@includemdc-button-container-fill-color(lightblue);}

Step 3a: Use Compiled CSS

If you performedStep 3, then you can skip toStep 4.

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:

import'@material/react-button/dist/button.css';

If you want to use the minified version, the import instead looks like:

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:

importReact,{Component}from'react';importButtonfrom'@material/react-button';import'./App.scss';// add the appropriate line(s) in Step 3a if you are using compiled CSS instead.classAppextendsComponent{render(){return(<div><ButtonraisedclassName='button-alternate'onClick={()=>console.log('clicked!')}>          Click Me!</Button></div>);}}exportdefaultApp;

You can also use these same configurations for your own Webpack build pipeline withoutcreate-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 ourDiscord Channel.

About

Material Components for React (MDC React)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors54


[8]ページ先頭

©2009-2025 Movatter.jp