blob: d50a9a8e138498bda9c26a7392251d9557a0f12c [file] [log] [blame]
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="A front-end template that helps you build fast, modern mobile web apps.">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>Material Design Lite</title>
<!-- Add to homescreen -->
<link rel="manifest" href="manifest.json">
<!-- Fallback to homescreen for Chrome <39 on Android -->
<meta name="mobile-web-app-capable" content="yes">
<meta name="application-name" content="Material Design Lite">
<link rel="icon" sizes="192x192" href="../assets/android-desktop.png">
<!-- Add to homescreen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="Material Design Lite">
<link rel="apple-touch-icon" href="../assets/ios-desktop.png">
<!-- TODO: Tile icon for Win8 (144x144 + tile color) -->
<!-- <meta name="msapplication-TileImage" content="images/touch/ms-touch-icon-144x144-precomposed.png"> -->
<!-- <meta name="msapplication-TileColor" content="#3372DF"> -->
<meta name="theme-color" content="#263238">
<link rel="shortcut icon" href="../assets/favicon.png">
<!-- SEO: If your mobile URL is different from the desktop URL, add a canonical link to the desktop page https://developers.google.com/webmasters/smartphone-sites/feature-phones -->
<!--
<link rel="canonical" href="http://www.example.com/">
-->
<!-- Page styles -->
<link rel="stylesheet" href="../assets/prism-default.css">
<link rel="stylesheet" href="../material.min.css">
<link rel="stylesheet" href="../assets/main.css">
<!-- Fonts -->
<link href='https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="started">
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID -->
<script>
// if (document.location.hostname !== 'localhost' &&
// document.location.hostname !== '127.0.0.1' &&
// document.location.hostname.search('.corp.') === -1) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-25993200-9', 'auto');
// If a specific component page is loaded directly we'll attribute the
// page view to the specific component's page
if (window.location.pathname.indexOf('/components/') !== -1 &&
window.location.hash.indexOf('-section') !== -1) {
ga('send', 'pageview', '/components/' +
window.location.hash.split('#')[1].split('/')[0]);
} else {
ga('send', 'pageview');
}
// }
// Setup error tracking before anything else runs.
window.onerror = function(message, file, lineNumber, columnNumber, error) {
try {
if (error !== undefined) {
message = error.stack;
}
ga('send', 'event', 'error', file + ':' + lineNumber, String(message));
} catch (e) {
// no-op
}
};
</script>
<div class="image-preloader"></div>
<div class="docs-layout mdl-layout mdl-js-layout">
<header class="docs-layout-header mdl-layout__header">
<div class="mdl-layout__header-row">
<span class="docs-layout-title mdl-layout-title"><a href="../">Material<br>Design<br>Lite</a></span>
</div>
<div class="docs-navigation__container">
<nav class="docs-navigation mdl-navigation">
<a href="../index.html" class="mdl-navigation__link about">About</a>
<a href="../started/index.html" class="mdl-navigation__link started">Getting Started</a>
<a href="../templates/index.html" class="mdl-navigation__link templates">Templates</a>
<a href="../components/index.html" class="mdl-navigation__link components">Components</a>
<a href="../styles/index.html" class="mdl-navigation__link styles">Styles</a>
<a href="../customize/index.html" class="mdl-navigation__link customize">Customize</a>
<a href="../showcase/index.html" class="mdl-navigation__link showcase">Showcase</a>
<a href="../faq/index.html" class="mdl-navigation__link faq">FAQ</a>
<div class="spacer"></div>
<a href="https://github.com/google/material-design-lite" class="mdl-navigation__link mdl-navigation__link--icon github"><i class="material-icons">link</i><span>GitHub</span></a>
<a href="../started/index.html#download" class="mdl-navigation__link mdl-navigation__link--icon download">
<i class="material-icons">&#xE2C4;</i><span>Download</span>
<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--fab mdl-button--mini-fab mdl-color--lime-A200">
<i class="material-icons">&#xE2C4;</i>
</button>
</a>
</nav>
</div>
<i class="material-icons scrollindicator scrollindicator--right">&#xE315;</i>
<i class="material-icons scrollindicator scrollindicator--left">&#xE314;</i>
</header>
<main class="docs-layout-content mdl-layout__content mdl-color-text--grey-600">
<div class="content mdl-grid mdl-grid--no-spacing" id="content">
<div class="subpageheader mdl-cell--12-col">Getting started</div>
<script src="../assets/snippets.js"></script>
<div class="docs-text-styling">
<section class="docs-toc">
<h3>Contents</h3>
<nav class="section-content">
<ul>
<li><a href="#download">Include the master CSS &amp; JavaScript</a></li>
<li><a href="#use-components">Use the components</a></li>
<li><a href="#general-rules">General rules and principles</a></li>
<li><a href="#dynamic">Use MDL on dynamic websites</a></li>
<li><a href="#responsibilities">What are MDL's responsibilities?</a></li>
<li><a href="#whats-next">What's next?</a></li>
<li><a href="#license">License</a></li>
</ul>
</nav>
</section>
<section id="download">
<h3>Include the master CSS &amp; JavaScript</h3>
<div class="section-content">
<p>
Include the Material Lite CSS and JavaScript files in each HTML page in your project. We recommend that you use the <strong>files hosted on our CDN</strong>. You can also <strong>customize and download</strong> them to host them yourself, <strong>build</strong> them from our source code or install them in your <strong>npm</strong>/<strong>Bower</strong> project.
</p>
<div class="mdl-tabs mdl-js-tabs">
<div class="mdl-tabs__tab-bar">
<a href="#tab1" class="mdl-tabs__tab is-active">Hosted</a>
<a href="#tab2" class="mdl-tabs__tab">Download</a>
<a href="#tab3" class="mdl-tabs__tab">Build</a>
<a href="#tab4" class="mdl-tabs__tab">Bower</a>
<a href="#tab5" class="mdl-tabs__tab">npm</a>
</div>
<div class="mdl-tabs__panel is-active" id="tab1">
<div class="code-with-text">
Just add the following <code>&lt;link&gt;</code> and <code>&lt;script&gt;</code> elements into your HTML pages (27kB gzipped):
<pre class="language-markup"><code>&lt;link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"&gt;
&lt;link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css"&gt;
&lt;script defer src="https://code.getmdl.io/1.3.0/material.min.js"&gt;&lt;/script&gt;</code></pre>
</div>
<h4>Choose color scheme</h4>
<p>
<a href="http://www.google.com/design/spec/style/color.html">Color schemes used in Material Design</a> are based on a primary and an accent colors which you may want to personalize. These colors are specified in the CSS file name by following this pattern: <code>material.{primary}-{accent}.min.css</code> (e.g. <code>material.indigo-pink.min.css</code>). Our CDN hosts a number of color combinations based on common Material Design colors. To discover and preview available color combinations use our <a href="../customize/index.html">Customize and Preview tool</a>.
</p>
</div>
<div class="mdl-tabs__panel" id="tab2">
<p>
Download the minified CSS and Javascript now (27kB gzipped):
</p>
<div class="download-button-container">
<a href="https://code.getmdl.io/1.3.0/mdl.zip">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect">
Download MDL v1.3.0
</button>
</a>
</div>
<div class="code-with-text">
Refer to these files by adding a <code>&lt;link&gt;</code> and a <code>&lt;script&gt;</code> elements into your HTML pages and also include the Material Icon font:
<pre class="language-markup"><code>&lt;link rel="stylesheet" href="./material.min.css"&gt;
&lt;script src="./material.min.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"&gt;</code></pre>
</div>
<h4>Choose color scheme</h4>
<p>
<a href="http://www.google.com/design/spec/style/color.html">Color schemes used in Material Design</a> are based on a primary and an accent colors which you may want to personalize. Use the <a href="../customize/index.html">Customize and Preview tool</a> to select and preview primary and accent colors combinations for your site. Then download your customized Material Design Lite CSS using the button and simply replace the `material.min.css` with the customized one.
</p>
</div>
<div class="mdl-tabs__panel" id="tab3">
<p>
Our source code is hosted <a href="https://github.com/google/material-design-lite">on GitHub</a>. You'll need to download the code and build it.
</p>
<div class="code-with-text">
Run the following commands in a shell:
<pre class="language-bash"><code># Clone/copy the Material Design lite source code.
git clone https://github.com/google/material-design-lite.git
# Go into the newly created folder containing the source code.
cd material-design-lite
# Install necessary dependencies.
npm install && npm install -g gulp
# Build a production version of the components.
gulp</code></pre>
</div>
<p>You'll find the Material Design Lite library's file in the <code>dist</code> folder. Copy them to your project.
</p>
<div class="code-with-text">
Refer to these files by adding a <code>&lt;link&gt;</code> and a <code>&lt;script&gt;</code> element into your HTML pages and also include the Material Icon font:
<pre class="language-markup"><code>&lt;link rel="stylesheet" href="./material.min.css"&gt;
&lt;script src="./material.min.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"&gt;</code></pre>
</div>
<div class="caption">
<h4>
Note:
</h4>
Using this method you will not be able to customize the color scheme of the MDL elements. If you'd like to customize the color scheme prefer the CDN hosted or downloadable libraries. In this case use our <a href="../customize/index.html">Customize and Preview tool</a>.
</div>
</div>
<div class="mdl-tabs__panel" id="tab4">
<p>
Simply install Material Design Lite files in your <a href="http://bower.io/">Bower</a> enabled project using:
</p>
<div class="code-with-text">
Run the following command in a shell:
<pre class="language-bash"><code>bower install material-design-lite --save</code></pre>
</div>
<p>
This will install the Material Design Lite library files in your project's <code>bower_components</code> folder.
</p>
<div class="code-with-text">
Refer to these files by adding a <code>&lt;link&gt;</code> and a <code>&lt;script&gt;</code> element into your HTML pages and also include the Material Icon font:
<pre class="language-markup"><code>&lt;link rel="stylesheet" href="/bower_components/material-design-lite/material.min.css"&gt;
&lt;script src="/bower_components/material-design-lite/material.min.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"&gt;</code></pre>
</div>
<div class="caption">
<h4>
Note:
</h4>
Using this method you will not be able to customize the color scheme of the MDL elements. If you'd like to customize the color scheme prefer the CDN hosted or downloadable libraries. In this case use our <a href="../customize/index.html">Customize and Preview tool</a>.
</div>
</div>
<div class="mdl-tabs__panel" id="tab5">
<p>
Simply install Material Design Lite files in your <a href="https://www.npmjs.com/">npm</a> enabled project using:
</p>
<div class="code-with-text">
Run the following command in a shell:
<pre class="language-bash"><code>npm install material-design-lite --save</code></pre>
</div>
<p>
This will install the Material Design Lite library files in your project's <code>node_modules</code> folder.
</p>
<div class="code-with-text">
Refer to these files by adding a <code>&lt;link&gt;</code> and a <code>&lt;script&gt;</code> element into your HTML pages and also include the Material Icon font:
<pre class="language-markup"><code>&lt;link rel="stylesheet" href="/node_modules/material-design-lite/material.min.css"&gt;
&lt;script src="/node_modules/material-design-lite/material.min.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"&gt;</code></pre>
</div>
<div class="caption">
<h4>
Note:
</h4>
Using this method you will not be able to customize the color scheme of the MDL elements. If you'd like to customize the color scheme prefer the CDN hosted or downloadable libraries. In this case use our <a href="../customize/index.html">Customize and Preview tool</a>.
</div>
</div>
</div>
<p>
That's it! You are now ready to add MDL components on your site.
</p>
</div>
</section>
<section id="use-components">
<h3>Use the components</h3>
<div class="section-content">
<p>
You'll find below a couple of examples of MDL <a href="../components/index.html#buttons-section">Button</a> elements: a Button with ripples and a FAB Button. Just copy &amp; paste the corresponding source code in the <code>&lt;body&gt;</code> of an HTML page of your project and the elements will render as shown below.
</p>
<!-- Generating snippets -->
<div class="snippet-group">
<div class="snippet-header">
<div class="snippet-demos">
<div class="snippet-demo-padding"></div>
<div class="snippet-demo">
<div class="snippet-demo-container demo-button demo-button__raised-ripple-accent">
<!-- Accent-colored raised button with ripple -->
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
Button
</button>
</div>
</div>
<div class="snippet-demo">
<div class="snippet-demo-container demo-button demo-button__fab-colored">
<!-- Colored FAB button -->
<button class="mdl-button mdl-js-button mdl-button--fab mdl-button--colored">
<i class="material-icons">add</i>
</button>
</div>
</div>
<div class="snippet-demo-padding"></div>
</div>
<div class="snippet-captions">
<div class="snippet-caption-padding"></div>
<div class="snippet-caption">
Raised button
</div>
<div class="snippet-caption">
Colored FAB
</div>
<div class="snippet-caption-padding"></div>
</div>
</div>
<div class="snippet-code">
<pre class="language-markup codepen-button-enabled"><code id="button/raised-ripple-accent.html">&lt;!-- Accent-colored raised button with ripple --&gt;
&lt;button class=&quot;mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent&quot;&gt;
Button
&lt;/button&gt;
</code><div class="codepen-extra-css">&lt;style&gt;&lt;/style&gt;</div><code id="button/fab-colored.html">&lt;!-- Colored FAB button --&gt;
&lt;button class=&quot;mdl-button mdl-js-button mdl-button--fab mdl-button--colored&quot;&gt;
&lt;i class=&quot;material-icons&quot;&gt;add&lt;/i&gt;
&lt;/button&gt;
</code><div class="codepen-extra-css">&lt;style&gt;&lt;/style&gt;</div><div class="codepen-extra-css">&lt;style&gt;
body {
padding: 20px;
background: #fafafa;
position: relative;
}
&lt;/style&gt;</div><form class="codepen-button" action="https://codepen.io/pen/define" method="POST" target="_blank"></form></pre>
</div>
</div>
<p>
MDL elements can be tweaked and configured by adding CSS classes. For example adding <code>mdl-js-ripple-effect</code> to an MDL <a href="../components/index.html#buttons-section">Button</a> will add a Ripple effect when the button is clicked and adding <code>mdl-button--fab</code> will change the style of the button to a FAB button.
</p>
<p>
There are many other elements available such as <a href="../components/index.html#cards-section">Card containers</a>, <a href="../components/index.html#sliders-section">Sliders</a>, <a href="../components/index.html#tables-section">Tables</a>, <a href="../components/index.html#menus-section">Menus</a>... For the complete set of MDL elements and options have a look at the <a href="../components/index.html">components</a> page.
</p>
<p>
We also recommend that you check out our <a href="../templates/index.html">templates</a>. These are ready to use website templates using MDL components. Feel free to have a look at them to get started quickly on your next project.
</p>
</div>
</section>
<section id="general-rules">
<h3>General rules and principles</h3>
<div class="section-content">
<p>
In general, follow these basic steps to use an MDL component in your HTML page:
</p>
<ol>
<li>Start with a standard HTML element, such as <code>&lt;button&gt;</code>, <code>&lt;div&gt;</code>, or <code>&lt;ul&gt;</code>, depending on the MDL component you want to use. This establishes the element in the page and readies it for MDL modification.</li>
<li>Add one or more MDL-specific CSS classes to the element, such as <code>mdl-button</code> or <code>mdl-tabs__panel</code>, again depending on the component. The classes apply the MDL enhancements to the element and turn it into an MDL component.</li>
</ol>
<p>
Remember to include the <a href="https://developers.google.com/speed/docs/insights/ConfigureViewport">meta viewport</a> tag in your document so mobile devices will render correctly.
</p>
<pre class="language-markup"><code>&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"></code></pre>
<div class="caption">
<h4>
A note about HTML elements and MDL CSS classes
</h4>
Material Design Lite uses namespaced <a href="https://en.bem.info/method/">BEM</a> classes—which can apply to almost any HTML element—to construct components. For some components you can use almost any element. The examples in <a href="../components/index.html">each component's documentation</a> use elements that perform well as that component. If you must use elements other than those shown in the examples, we encourage you to experiment to find the best combination of HTML elements and MDL CSS classes for your application.
</div>
</div>
</section>
<section id="dynamic">
<h3>Use MDL on dynamic websites</h3>
<div class="section-content">
<p>
Material Design Lite will automatically register and render all elements marked with MDL classes upon page load.
However in the case where you are creating DOM elements dynamically you need to register new elements using the <code>upgradeElement</code> function. Here is how you can dynamically create the same raised button with ripples shown in the section above:
</p>
<pre class="language-markup codepen-button-enabled"><code>&lt;div id="container"/&gt;
&lt;script&gt;
var button = document.createElement('button');
var textNode = document.createTextNode('Click Me!');
button.appendChild(textNode);
button.className = 'mdl-button mdl-js-button mdl-js-ripple-effect';
componentHandler.upgradeElement(button);
document.getElementById('container').appendChild(button);
&lt;/script&gt;</code><form class="codepen-button" action="https://codepen.io/pen/define" method="POST" target="_blank"></form></pre>
</div>
</section>
<section id="responsibilities">
<h3>What are MDL's responsibilities?</h3>
<div class="section-content">
<p>
Material Design Lite is built to provide a lightweight and basic set of Material Design components and templates for web sites.
The project does not intend to provide structures to create all possible UX needs, but to provide a low-friction Material Design implementation you can build on.
Even within Material Design itself, cards specifically, it is unfeasible to provide every combination in a seamless manner.
When you find something not provided, such as dropdowns in the drawer, you may need to code your own component.
</p>
<p>
The team is committed to providing a great experience to developers while staying true to the promise of lite.
</p>
</div>
</section>
<section id="whats-next">
<h3>What's next?</h3>
<div class="section-content">
<p>
Detailed instructions for using the components, including MDL classes and their effects, coding considerations, and configuration options, can be found in the <a href="../components/index.html">components</a> page. Example of sites using MDL elements together can be found in the <a href="../templates/index.html">templates</a> page.
</p>
</div>
</section>
<section id="license">
<h3>License</h3>
<div class="section-content">
<p>
Copyright Google, 2015. Licensed under an Apache-2 license.
</p>
</div>
</section>
</div>
</div>
<section class="docs-text-styling download mdl-color--grey-800">
<a href="../started/index.html#download" class="mdl-color-text--grey-50">Download Kit</a>
</section>
<footer class="docs-text-styling docs-footer mdl-mini-footer mdl-color--grey-900">
<ul>
<li class="mdl-mini-footer--social-btn">
<a href="https://twitter.com/googledesign" class="social-btn social-btn__twitter" role="button" title="Twitter"></a>
</li>
<li class="mdl-mini-footer--social-btn">
<a href="https://github.com/google/material-design-lite" class="social-btn social-btn__github" role="button" title="GitHub"></a>
</li>
<li class="mdl-mini-footer--social-btn">
<a href="https://plus.google.com/+googledesign" class="social-btn social-btn__gplus" role="button" title="Google+"></a>
</li>
</ul>
<ul class="docs-link-list">
<li><a class="mdl-color-text--grey-600" href="https://developers.google.com/web/starter-kit/">Web Starter Kit</a></li>
<li><a class="mdl-color-text--grey-600" href="https://github.com/google/material-design-lite/issues">Help</a></li>
</ul>
</footer>
</main>
</div>
<!-- IE Compatibility shims -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js""></script>
<![endif]-->
<!--[if IE]>
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.7/es5-shim.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/classlist/2014.01.31/classList.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/selectivizr/1.0.2/selectivizr-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/flexie/1.0.3/flexie.min.js"></script>
<link href="../assets/ie.css" rel="stylesheet">
<![endif]-->
<!-- end shims -->
<!-- Material Design Lite -->
<script src="../material.min.js"></script>
<!-- Add Copy-to-CodePen buttons to code blocks -->
<script src="../assets/codepen.js"></script>
<!-- Enable Prism syntax highlighting -->
<script src="../assets/prism.js"></script>
<script src="../assets/prism-markup.min.js"></script>
<script src="../assets/prism-javascript.min.js"></script>
<script src="../assets/prism-css.min.js"></script>
<script src="../assets/prism-bash.min.js"></script>
<script src="../assets/main.js"></script>
<!-- Built with love using Material Design Lite -->
</body>
</html>