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>tooltip</strong> component is an enhanced version of the standard HTML tooltip as produced by the <code>title</code> attribute. A tooltip consists of text and/or an image that clearly communicates additional information about an element when the user hovers over or, in a touch-based UI, touches the element. The MDL tooltip component is pre-styled (colors, fonts, and other settings are contained in <em>material.min.css</em>) to provide a vivid, attractive visual element that displays related but typically non-essential content, e.g., a definition, clarification, or brief instruction.</p> |
| 6 | <p>Tooltips are a ubiquitous feature of most user interfaces, regardless of a site's content or function. Their design and use is an important factor in the overall user experience. See the tooltip component's <a href="http://www.google.com/design/spec/components/tooltips.html">Material Design specifications page</a> for details.</p> |
| 7 | <h3 id="to-include-an-mdl-tooltip-component-">To include an MDL <strong>tooltip</strong> component:</h3> |
| 8 | <p> 1. Code an element, such as a <code><div></code>, <code><p></code>, or <code><span></code>, and style it as desired; this will be the tooltip's target. Include an <code>id</code> attribute and unique value to link the container to its tooltip.</p> |
| 9 | <pre><code class="lang-html"><p id="tt1">HTML</p> |
| 10 | </code></pre> |
| 11 | <p> 2. Following the target element, code a second element, such as a <code><div></code>, <code><p></code>, or <code><span></code>; this will be the tooltip itself. Include a <code>for</code> (or <code>data-mdl-for</code>) attribute whose value matches that of the target's <code>id</code>.</p> |
| 12 | <pre><code class="lang-html"><p id="tt1">HTML</p> |
| 13 | <span for="tt1">HyperText Markup Language</span> |
| 14 | </code></pre> |
| 15 | <p> 3. Add one or more MDL classes, separated by spaces, to the tooltip element using the <code>class</code> attribute.</p> |
| 16 | <pre><code class="lang-html"><p id="tt1">HTML</p> |
| 17 | <span for="tt1" class="mdl-tooltip">HyperText Markup Language</span> |
| 18 | </code></pre> |
| 19 | <p>The tooltip component is ready for use.</p> |
| 20 | <h4 id="examples">Examples</h4> |
| 21 | <p>A target with a simple text tooltip.</p> |
| 22 | <pre><code class="lang-html"><p>HTML is related to but different from <span id="xml"><i>XML</i></span>.</p> |
| 23 | <span class="mdl-tooltip" for="xml">eXtensible Markup Language</span> |
| 24 | </code></pre> |
| 25 | <p>A target with "rich" (containing HTML markup) tooltip text.</p> |
| 26 | <pre><code class="lang-html"><p>HTML is related to but different from <span id="xml"><i>XML</i></span>.</p> |
| 27 | <span class="mdl-tooltip" for="xml">e<b>X</b>tensible <b>M</b>arkup <b>L</b>anguage</span> |
| 28 | </code></pre> |
| 29 | <p>A target with a long text tooltip that automatically wraps.</p> |
| 30 | <pre><code class="lang-html"><p>HTML is related to but different from <span id="xml"><i>XML</i></span>.</p> |
| 31 | <span class="mdl-tooltip" for="xml">XML is an acronym for eXtensible Markup Language</span> |
| 32 | </code></pre> |
| 33 | <p>A target with tooltip text in a larger font size.</p> |
| 34 | <pre><code class="lang-html"><p>HTML is related to but different from <span id="xml"><i>XML</i></span>.</p> |
| 35 | <span class="mdl-tooltip mdl-tooltip--large" for="xml">eXtensible Markup Language</span> |
| 36 | </code></pre> |
| 37 | <p>A target with a tooltip containing both an image and text.</p> |
| 38 | <pre><code class="lang-html"><p>HTML is related to but different from <span id="xml"><i>XML</i></span>.</p> |
| 39 | <span class="mdl-tooltip" for="xml"> |
| 40 | <img src="xml-logo-small.png" width="20" height="10"> eXtensible Markup Language</span> |
| 41 | </code></pre> |
| 42 | <h2 id="configuration-options">Configuration options</h2> |
| 43 | <p>The MDL CSS classes apply various predefined visual enhancements to the tooltip. The table below lists the available classes and their effects.</p> |
| 44 | <table> |
| 45 | <thead> |
| 46 | <tr> |
| 47 | <th>MDL class</th> |
| 48 | <th>Effect</th> |
| 49 | <th>Remarks</th> |
| 50 | </tr> |
| 51 | </thead> |
| 52 | <tbody> |
| 53 | <tr> |
| 54 | <td><code>mdl-tooltip</code></td> |
| 55 | <td>Defines a container as an MDL tooltip</td> |
| 56 | <td>Required on tooltip container element</td> |
| 57 | </tr> |
| 58 | <tr> |
| 59 | <td><code>mdl-tooltip--large</code></td> |
| 60 | <td>Applies large-font effect</td> |
| 61 | <td>Optional; goes on tooltip container element</td> |
| 62 | </tr> |
| 63 | <tr> |
| 64 | <td><code>mdl-tooltip--left</code></td> |
| 65 | <td>Positions the tooltip to the left of the target</td> |
| 66 | <td>Optional; goes on tooltip container element</td> |
| 67 | </tr> |
| 68 | <tr> |
| 69 | <td><code>mdl-tooltip--right</code></td> |
| 70 | <td>Positions the tooltip to the right of the target</td> |
| 71 | <td>Optional; goes on tooltip container element</td> |
| 72 | </tr> |
| 73 | <tr> |
| 74 | <td><code>mdl-tooltip--top</code></td> |
| 75 | <td>Positions the tooltip to the top of the target</td> |
| 76 | <td>Optional; goes on tooltip container element</td> |
| 77 | </tr> |
| 78 | <tr> |
| 79 | <td><code>mdl-tooltip--bottom</code></td> |
| 80 | <td>Positions the tooltip to the bottom of the target</td> |
| 81 | <td>Optional; goes on tooltip container element</td> |
| 82 | </tr> |
| 83 | </tbody> |
| 84 | </table> |
| 85 | |
| 86 | |