blob: 3aac0fc92b7f3ef2fabbc65b71b0a4da309f5c9f [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001
2
3
4<h2 id="introduction">Introduction</h2>
5<p>The Material Design Lite (MDL) <strong>chip</strong> component is a small, interactive element.
6Chips 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>&nbsp;1. Create a container element for the chip; typically <code>&lt;span&gt;</code> and <code>&lt;div&gt;</code> are used, but any container element should work equally well. If you need interactivity, use a <code>&lt;button&gt;</code>, or add the <code>tabindex</code> attribute to your container.</p>
9<pre><code class="lang-html">&lt;span&gt;
10&lt;/span&gt;
11</code></pre>
12<p>&nbsp;2. Add in the text wrapper and the MDL classes.</p>
13<pre><code class="lang-html">&lt;span class=&quot;mdl-chip&quot;&gt;
14 &lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
15&lt;/span&gt;
16</code></pre>
17<p>&nbsp;3. For deletable chips, add in the delete icon. This can be an <code>&lt;a&gt;</code>, <code>&lt;button&gt;</code> or non-interactive tags like <code>&lt;span&gt;</code>.</p>
18<pre><code class="lang-html">&lt;span class=&quot;mdl-chip&quot;&gt;
19 &lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
20 &lt;a href=&quot;#&quot; class=&quot;mdl-chip__action&quot;&gt;&lt;i class=&quot;material-icons&quot;&gt;cancel&lt;/i&gt;&lt;/a&gt;
21&lt;/span&gt;
22</code></pre>
23<p>&nbsp;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>&lt;img&gt;</code> tag, but other types of content can be used with a little extra supporting css.</p>
24<pre><code class="lang-html">&lt;span class=&quot;mdl-chip&quot;&gt;
25 &lt;span class=&quot;mdl-chip__contact mdl-color--teal mdl-color-text--white&quot;&gt;A&lt;/span&gt;
26 &lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
27 &lt;a href=&quot;#&quot; class=&quot;mdl-chip__action&quot;&gt;&lt;i class=&quot;material-icons&quot;&gt;cancel&lt;/i&gt;&lt;/a&gt;
28&lt;/span&gt;
29</code></pre>
30<h2 id="examples">Examples</h2>
31<p>A button based contact chip whose contact image is a <code>&lt;span&gt;</code> with a <code>background-image</code>.</p>
32<pre><code class="lang-html">&lt;style&gt;
33 .demo-chip .mdl-chip__contact {
34 background-image: url(&quot;./path/to/image&quot;);
35 background-size: cover;
36 }
37&lt;/style&gt;
38
39&lt;button class=&quot;mdl-chip demo-chip&quot;&gt;
40 &lt;span class=&quot;mdl-chip__contact&quot;&gt;&amp;nbsp;&lt;/span&gt;
41 &lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
42 &lt;a href=&quot;#&quot; class=&quot;mdl-chip__action&quot;&gt;&lt;i class=&quot;material-icons&quot;&gt;cancel&lt;/i&gt;&lt;/a&gt;
43&lt;/button&gt;
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 &quot;outer&quot; 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 &quot;outer&quot; container</td>
64</tr>
65<tr>
66<td><code>mdl-chip__text</code></td>
67<td>Defines element as the chip&#39;s text</td>
68<td>Required on &quot;inner&quot; text container</td>
69</tr>
70<tr>
71<td><code>mdl-chip__action</code></td>
72<td>Defines element as the chip&#39;s action</td>
73<td>Required on &quot;inner&quot; action container, if present</td>
74</tr>
75<tr>
76<td><code>mdl-chip__contact</code></td>
77<td>Defines element as the chip&#39;s contact container</td>
78<td>Required on &quot;inner&quot; contact container, if the <code>mdl-chip--contact</code> class is present on &quot;outer&quot; container</td>
79</tr>
80</tbody>
81</table>
82
83