Material Components
Modular and customizable Material Design UI components for the web
README
Material Components for the web
NOTE: Material Components Web tends to release breaking changes on a monthly basis, but follows
semver so you can control when you incorporate them.
We typically follow a 2-week release schedule which includes one major release per month with breaking changes,
and intermediate patch releases with bug fixes.
Important links
Quick start
Using via CDN
- ``` html
- <link rel="stylesheet" href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css">
- <label class="mdc-text-field mdc-text-field--filled">
- <span class="mdc-text-field__ripple"></span>
- <span class="mdc-floating-label" id="my-label">Label</span>
- <input type="text" class="mdc-text-field__input" aria-labelledby="my-label">
- <span class="mdc-line-ripple"></span>
- </label>
- <script src="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.js"></script>
- <script>
- mdc.textField.MDCTextField.attachTo(document.querySelector('.mdc-text-field'));
- </script>
- ```
Please see quick start demo on codepen for full example.
Using NPM
This guide assumes you have webpack configured to compile Sass into CSS. To configure webpack, please see the full getting started guide. You can also see the final code and result in the Material Starter Kit.
- ```
- npm install @material/textfield
- ```
HTML
- ``` html
- <label class="mdc-text-field mdc-text-field--filled">
- <span class="mdc-text-field__ripple"></span>
- <input type="text" class="mdc-text-field__input" aria-labelledby="my-label">
- <span class="mdc-floating-label" id="my-label">Label</span>
- <span class="mdc-line-ripple"></span>
- </label>
- ```
CSS
- ```scss
- @use "@material/floating-label/mdc-floating-label";
- @use "@material/line-ripple/mdc-line-ripple";
- @use "@material/notched-outline/mdc-notched-outline";
- @use "@material/textfield";
- @include textfield.core-styles;
- ```
JavaScript
- ``` js
- import {MDCTextField} from '@material/textfield';
- const textField = new MDCTextField(document.querySelector('.mdc-text-field'));
- ```
Please see quick start demo on glitch for full example.