Giter VIP home page Giter VIP logo

material-components-web's Introduction

Build Status codecov Chat

Material Components for the web

Material Components for the web (MDC Web) helps developers execute Material Design. Developed by a core team of engineers and UX designers at Google, these components enable a reliable development workflow to build beautiful and functional web projects.

Material Components for the web is the successor to Material Design Lite, and has 3 high-level goals:

MDC Web strives to seamlessly incorporate into a wider range of usage contexts, from simple static websites to complex, JavaScript-heavy applications to hybrid client/server rendering systems. In short, whether you're already heavily invested in another framework or not, it should be easy to incorporate Material Components into your site in a lightweight, idiomatic fashion.

Demos (updated with every release)

Quick start

Note: This guide assumes you have npm installed locally.

Include CSS for a component

Note: This guide assumes you have webpack configured to compile Sass into CSS. See this getting started guide for pointers on how to configure webpack.

To include the Sass files for the Material Design button, install the Node dependency:

npm install @material/button

Then import the Sass files for @material/button into your application. You can also use Sass mixins to customize the button:

@import "@material/button/mdc-button";

.foo-button {
  @include mdc-button-ink-color(teal);
  @include mdc-states(teal);
}

@material/button has documentation about the required HTML of a button. Update your application's HTML to include this HTML, and add the foo-button class onto the element:

<button class="foo-button mdc-button">
  Button
</button>

You also need to configure the sass-loader to understand the @material syntax. Update your webpack.config.js by changing { loader: 'sass-loader' } to:

{
  loader: 'sass-loader',
  options: {
    importer: function(url, prev) {
      if(url.indexOf('@material') === 0) {
        var filePath = url.split('@material')[1];
        var nodeModulePath = `./node_modules/@material/${filePath}`;
        return { file: require('path').resolve(nodeModulePath) };
      }
      return { file: url };
    }
  }
}

This will produce a customized Material Design button!

Button

Include JavaScript for a component

Note: This guide assumes you have webpack configured to compile ES2015 into JavaScript. See this getting started guide for pointers on how to configure webpack.

To include the ES2015 files for the Material Design ripple, install the Node dependency:

npm install @material/ripple

Then import the ES2015 file for @material/ripple into your application, and initialize an MDCRipple with a DOM element:

import {MDCRipple} from '@material/ripple';
const ripple = new MDCRipple(document.querySelector('.foo-button'));

This will produce a Material Design ripple on the button!

Button with Ripple

Useful Links

Browser Support

We officially support the last two versions of every major browser. Specifically, we test on the following browsers:

  • Chrome
  • Safari
  • Firefox
  • IE 11/Edge
  • Opera
  • Mobile Safari
  • Chrome on Android

material-components-web's People

Contributors

addyosmani avatar surma avatar garbee avatar sgomes avatar traviskaufman avatar sindresorhus avatar lynnmercier avatar acdvorak avatar kfranqueiro avatar yeelan0319 avatar mco-gh avatar amsheehan avatar greenkeeper[bot] avatar williamernest avatar bonniezhou avatar x1ddos avatar jasonmayes avatar nicolasgarnier avatar samthor avatar patrickrodee avatar touficbatache avatar passy avatar samccone avatar anton-kachurin avatar bwobrien avatar bbosman avatar jonathanzong avatar moog16 avatar paulkinlan avatar mikemitterer avatar

Watchers

James Cloos avatar George Tzikas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.