blob: 3aac0fc92b7f3ef2fabbc65b71b0a4da309f5c9f [file] [log] [blame]
<h2 id="introduction">Introduction</h2>
<p>The Material Design Lite (MDL) <strong>chip</strong> component is a small, interactive element.
Chips are commonly used for contacts, text, rules, icons, and photos.</p>
<h2 id="to-include-an-mdl-chip-component-">TO INCLUDE AN MDL CHIP COMPONENT:</h2>
<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>
<pre><code class="lang-html">&lt;span&gt;
&lt;/span&gt;
</code></pre>
<p>&nbsp;2. Add in the text wrapper and the MDL classes.</p>
<pre><code class="lang-html">&lt;span class=&quot;mdl-chip&quot;&gt;
&lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
&lt;/span&gt;
</code></pre>
<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>
<pre><code class="lang-html">&lt;span class=&quot;mdl-chip&quot;&gt;
&lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
&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;
&lt;/span&gt;
</code></pre>
<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>
<pre><code class="lang-html">&lt;span class=&quot;mdl-chip&quot;&gt;
&lt;span class=&quot;mdl-chip__contact mdl-color--teal mdl-color-text--white&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
&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;
&lt;/span&gt;
</code></pre>
<h2 id="examples">Examples</h2>
<p>A button based contact chip whose contact image is a <code>&lt;span&gt;</code> with a <code>background-image</code>.</p>
<pre><code class="lang-html">&lt;style&gt;
.demo-chip .mdl-chip__contact {
background-image: url(&quot;./path/to/image&quot;);
background-size: cover;
}
&lt;/style&gt;
&lt;button class=&quot;mdl-chip demo-chip&quot;&gt;
&lt;span class=&quot;mdl-chip__contact&quot;&gt;&amp;nbsp;&lt;/span&gt;
&lt;span class=&quot;mdl-chip__text&quot;&gt;Chip Text&lt;/span&gt;
&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;
&lt;/button&gt;
</code></pre>
<h2 id="css-classes">CSS Classes</h2>
<table>
<thead>
<tr>
<th>MDL Class</th>
<th>Effect</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>mdl-chip</code></td>
<td>Defines element as an MDL chip container</td>
<td>Required on &quot;outer&quot; container</td>
</tr>
<tr>
<td><code>mdl-chip--contact</code></td>
<td>Defines an MDL chip as a contact style chip</td>
<td>Optional, goes on &quot;outer&quot; container</td>
</tr>
<tr>
<td><code>mdl-chip__text</code></td>
<td>Defines element as the chip&#39;s text</td>
<td>Required on &quot;inner&quot; text container</td>
</tr>
<tr>
<td><code>mdl-chip__action</code></td>
<td>Defines element as the chip&#39;s action</td>
<td>Required on &quot;inner&quot; action container, if present</td>
</tr>
<tr>
<td><code>mdl-chip__contact</code></td>
<td>Defines element as the chip&#39;s contact container</td>
<td>Required on &quot;inner&quot; contact container, if the <code>mdl-chip--contact</code> class is present on &quot;outer&quot; container</td>
</tr>
</tbody>
</table>