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>chip</strong> component is a small, interactive element. |
| 6 | Chips are commonly used for contacts, text, rules, icons, and photos.</p> |
| 7 | <h2 id="to-include-an-mdl-chip-component-">TO INCLUDE AN MDL CHIP COMPONENT:</h2> |
| 8 | <p> 1. Create a container element for the chip; typically <code><span></code> and <code><div></code> are used, but any container element should work equally well. If you need interactivity, use a <code><button></code>, or add the <code>tabindex</code> attribute to your container.</p> |
| 9 | <pre><code class="lang-html"><span> |
| 10 | </span> |
| 11 | </code></pre> |
| 12 | <p> 2. Add in the text wrapper and the MDL classes.</p> |
| 13 | <pre><code class="lang-html"><span class="mdl-chip"> |
| 14 | <span class="mdl-chip__text">Chip Text</span> |
| 15 | </span> |
| 16 | </code></pre> |
| 17 | <p> 3. For deletable chips, add in the delete icon. This can be an <code><a></code>, <code><button></code> or non-interactive tags like <code><span></code>.</p> |
| 18 | <pre><code class="lang-html"><span class="mdl-chip"> |
| 19 | <span class="mdl-chip__text">Chip Text</span> |
| 20 | <a href="#" class="mdl-chip__action"><i class="material-icons">cancel</i></a> |
| 21 | </span> |
| 22 | </code></pre> |
| 23 | <p> 4. Contact chips need to have the <code>mdl-chip--contact</code> class added to the container, along with another container for the contact icon. The icon container for photos is typically an <code><img></code> tag, but other types of content can be used with a little extra supporting css.</p> |
| 24 | <pre><code class="lang-html"><span class="mdl-chip"> |
| 25 | <span class="mdl-chip__contact mdl-color--teal mdl-color-text--white">A</span> |
| 26 | <span class="mdl-chip__text">Chip Text</span> |
| 27 | <a href="#" class="mdl-chip__action"><i class="material-icons">cancel</i></a> |
| 28 | </span> |
| 29 | </code></pre> |
| 30 | <h2 id="examples">Examples</h2> |
| 31 | <p>A button based contact chip whose contact image is a <code><span></code> with a <code>background-image</code>.</p> |
| 32 | <pre><code class="lang-html"><style> |
| 33 | .demo-chip .mdl-chip__contact { |
| 34 | background-image: url("./path/to/image"); |
| 35 | background-size: cover; |
| 36 | } |
| 37 | </style> |
| 38 | |
| 39 | <button class="mdl-chip demo-chip"> |
| 40 | <span class="mdl-chip__contact">&nbsp;</span> |
| 41 | <span class="mdl-chip__text">Chip Text</span> |
| 42 | <a href="#" class="mdl-chip__action"><i class="material-icons">cancel</i></a> |
| 43 | </button> |
| 44 | </code></pre> |
| 45 | <h2 id="css-classes">CSS Classes</h2> |
| 46 | <table> |
| 47 | <thead> |
| 48 | <tr> |
| 49 | <th>MDL Class</th> |
| 50 | <th>Effect</th> |
| 51 | <th>Remarks</th> |
| 52 | </tr> |
| 53 | </thead> |
| 54 | <tbody> |
| 55 | <tr> |
| 56 | <td><code>mdl-chip</code></td> |
| 57 | <td>Defines element as an MDL chip container</td> |
| 58 | <td>Required on "outer" container</td> |
| 59 | </tr> |
| 60 | <tr> |
| 61 | <td><code>mdl-chip--contact</code></td> |
| 62 | <td>Defines an MDL chip as a contact style chip</td> |
| 63 | <td>Optional, goes on "outer" container</td> |
| 64 | </tr> |
| 65 | <tr> |
| 66 | <td><code>mdl-chip__text</code></td> |
| 67 | <td>Defines element as the chip's text</td> |
| 68 | <td>Required on "inner" text container</td> |
| 69 | </tr> |
| 70 | <tr> |
| 71 | <td><code>mdl-chip__action</code></td> |
| 72 | <td>Defines element as the chip's action</td> |
| 73 | <td>Required on "inner" action container, if present</td> |
| 74 | </tr> |
| 75 | <tr> |
| 76 | <td><code>mdl-chip__contact</code></td> |
| 77 | <td>Defines element as the chip's contact container</td> |
| 78 | <td>Required on "inner" contact container, if the <code>mdl-chip--contact</code> class is present on "outer" container</td> |
| 79 | </tr> |
| 80 | </tbody> |
| 81 | </table> |
| 82 | |
| 83 | |