Skip to content

Instantly share code, notes, and snippets.

@abhiomkar
Last active November 16, 2018 18:55
Show Gist options
  • Save abhiomkar/ec167891e3f6420485d46be3cb038619 to your computer and use it in GitHub Desktop.
Save abhiomkar/ec167891e3f6420485d46be3cb038619 to your computer and use it in GitHub Desktop.
MDC Web / README (draft)

Version Build Status codecov Chat Screenshots

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.

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.

NOTE: Material Components Web follows semver and is still in version 0.x, which means it is regularly subject to breaking changes. We typically follow a 2-week release schedule which includes one minor release per month with breaking changes, and intermediate patch releases with bug fixes.

Important links

Quick start

Using via CDN

<!-- Required styles for MDC Web -->
<link rel="stylesheet" href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css">

<!-- Render textfield component -->
<div class="mdc-text-field">
  <input type="text" id="my-text-field" class="mdc-text-field__input">
  <label class="mdc-floating-label" for="my-text-field">Hint text</label>
  <div class="mdc-line-ripple"></div>
</div>

<!-- Required MDC Web JavaScript library -->
<script src="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.js"></script>
<!-- Instantiate single textfield component rendered in the document -->
<script>
  mdc.textField.MDCTextField.attachTo(document.querySelector('.mdc-text-field'));
</script>

Please see quick start demo on codepen for full example.

Using NPM

Install textfield node module to your project.

npm install @material/textfield
HTML

Sample usage of text field component. Please see MDC Textfield component page for more options.

<div class="mdc-text-field">
  <input type="text" id="my-text-field" class="mdc-text-field__input">
  <label class="mdc-floating-label" for="my-text-field">Hint text</label>
  <div class="mdc-line-ripple"></div>
</div>
CSS

Load styles required for text field component.

@import "@material/textfield/mdc-text-field";
JavaScript

Import MDCTextField module to instantiate text field component.

import {MDCTextField} from '@material/textfield/index';
const textField = new MDCTextField(document.querySelector('.mdc-text-field'));

This'll initialize text field component on a single .mdc-text-field element.

Please see getting started guide for pointers on how to configure webpack to bundle JavaScript & CSS.

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.

Thank you

Third-party services that we use and thankful of:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment