Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame^] | 1 | |
| 2 | |
| 3 | |
| 4 | <h2 id="introduction">Introduction</h2> |
| 5 | <p>The Material Design Lite (MDL) <strong>button</strong> component is an enhanced version of the standard HTML <code><button></code> element. A button consists of text and/or an image that clearly communicates what action will occur when the user clicks or touches it. The MDL button component provides various types of buttons, and allows you to add both display and click effects.</p> |
| 6 | <p>Buttons are a ubiquitous feature of most user interfaces, regardless of a site's content or function. Their design and use is therefore an important factor in the overall user experience. See the button component's <a href="http://www.google.com/design/spec/components/buttons.html">Material Design specifications page</a> for details.</p> |
| 7 | <p>The available button display types are <em>flat</em> (default), <em>raised</em>, <em>fab</em>, <em>mini-fab</em>, and <em>icon</em>; any of these types may be plain (light gray) or <em>colored</em>, and may be initially or programmatically <em>disabled</em>. The <em>fab</em>, <em>mini-fab</em>, and <em>icon</em> button types typically use a small image as their caption rather than text.</p> |
| 8 | <h3 id="to-include-an-mdl-button-component-">To include an MDL <strong>button</strong> component:</h3> |
| 9 | <p> 1. Code a <code><button></code> element. Include any desired attributes and values, such as an id or event handler, and add a text caption or image as appropriate.</p> |
| 10 | <pre><code class="lang-html"><button>Save</button> |
| 11 | </code></pre> |
| 12 | <p> 2. Add one or more MDL classes, separated by spaces, to the button using the <code>class</code> attribute.</p> |
| 13 | <pre><code class="lang-html"><button class="mdl-button mdl-js-button mdl-button--raised">Save</button> |
| 14 | </code></pre> |
| 15 | <p>The button component is ready for use.</p> |
| 16 | <h4 id="examples">Examples</h4> |
| 17 | <p>A button with the "raised" effect.</p> |
| 18 | <pre><code class="lang-html"><button class="mdl-button mdl-js-button mdl-button--raised">Save</button> |
| 19 | </code></pre> |
| 20 | <p>A button with the "fab" effect.</p> |
| 21 | <pre><code class="lang-html"><button class="mdl-button mdl-js-button mdl-button--fab">OK</button> |
| 22 | </code></pre> |
| 23 | <p>A button with the "icon" and "colored" effects.</p> |
| 24 | <pre><code class="lang-html"><button class="mdl-button mdl-js-button mdl-button--icon mdl-button--colored">?</button> |
| 25 | </code></pre> |
| 26 | <h2 id="configuration-options">Configuration options</h2> |
| 27 | <p>The MDL CSS classes apply various predefined visual and behavioral enhancements to the button. The table below lists the available classes and their effects.</p> |
| 28 | <table> |
| 29 | <thead> |
| 30 | <tr> |
| 31 | <th>MDL class</th> |
| 32 | <th>Effect</th> |
| 33 | <th>Remarks</th> |
| 34 | </tr> |
| 35 | </thead> |
| 36 | <tbody> |
| 37 | <tr> |
| 38 | <td><code>mdl-button</code></td> |
| 39 | <td>Defines button as an MDL component</td> |
| 40 | <td>Required</td> |
| 41 | </tr> |
| 42 | <tr> |
| 43 | <td><code>mdl-js-button</code></td> |
| 44 | <td>Assigns basic MDL behavior to button</td> |
| 45 | <td>Required</td> |
| 46 | </tr> |
| 47 | <tr> |
| 48 | <td>(none)</td> |
| 49 | <td>Applies <em>flat</em> display effect to button (default)</td> |
| 50 | <td></td> |
| 51 | </tr> |
| 52 | <tr> |
| 53 | <td><code>mdl-button--raised</code></td> |
| 54 | <td>Applies <em>raised</em> display effect</td> |
| 55 | <td>Mutually exclusive with <em>fab</em>, <em>mini-fab</em>, and <em>icon</em></td> |
| 56 | </tr> |
| 57 | <tr> |
| 58 | <td><code>mdl-button--fab</code></td> |
| 59 | <td>Applies <em>fab</em> (circular) display effect</td> |
| 60 | <td>Mutually exclusive with <em>raised</em>, <em>mini-fab</em>, and <em>icon</em></td> |
| 61 | </tr> |
| 62 | <tr> |
| 63 | <td><code>mdl-button--mini-fab</code></td> |
| 64 | <td>Applies <em>mini-fab</em> (small fab circular) display effect</td> |
| 65 | <td>Mutually exclusive with <em>raised</em>, <em>fab</em>, and <em>icon</em></td> |
| 66 | </tr> |
| 67 | <tr> |
| 68 | <td><code>mdl-button--icon</code></td> |
| 69 | <td>Applies <em>icon</em> (small plain circular) display effect</td> |
| 70 | <td>Mutually exclusive with <em>raised</em>, <em>fab</em>, and <em>mini-fab</em></td> |
| 71 | </tr> |
| 72 | <tr> |
| 73 | <td><code>mdl-button--colored</code></td> |
| 74 | <td>Applies <em>colored</em> display effect (primary or accent color, depending on the type of button)</td> |
| 75 | <td>Colors are defined in <code>material.min.css</code></td> |
| 76 | </tr> |
| 77 | <tr> |
| 78 | <td><code>mdl-button--primary</code></td> |
| 79 | <td>Applies <em>primary</em> color display effect</td> |
| 80 | <td>Colors are defined in <code>material.min.css</code></td> |
| 81 | </tr> |
| 82 | <tr> |
| 83 | <td><code>mdl-button--accent</code></td> |
| 84 | <td>Applies <em>accent</em> color display effect</td> |
| 85 | <td>Colors are defined in <code>material.min.css</code></td> |
| 86 | </tr> |
| 87 | <tr> |
| 88 | <td><code>mdl-js-ripple-effect</code></td> |
| 89 | <td>Applies <em>ripple</em> click effect</td> |
| 90 | <td>May be used in combination with any other classes</td> |
| 91 | </tr> |
| 92 | </tbody> |
| 93 | </table> |
| 94 | <blockquote> |
| 95 | <p><strong>Note:</strong> Disabled versions of all the available button types are provided, and are invoked with the standard HTML boolean attribute <code>disabled</code>. <code><button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" disabled>Raised Ripples Disabled</button></code>. Alternatively, the <code>mdl-button--disabled</code> class can be used to achieve the same style but it does not disable the functionality of the element. |
| 96 | This attribute may be added or removed programmatically via scripting.</p> |
| 97 | </blockquote> |
| 98 | |
| 99 | |