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>card</strong> component is a user interface element representing a virtual piece of paper that contains related data — such as a photo, some text, and a link — that are all about a single subject.</p> |
| 6 | <p>Cards are a convenient means of coherently displaying related content that is composed of different types of objects. They are also well-suited for presenting similar objects whose size or supported actions can vary considerably, like photos with captions of variable length. Cards have a constant width and a variable height, depending on their content.</p> |
| 7 | <p>Cards are a fairly new feature in user interfaces, and allow users an access point to more complex and detailed information. Their design and use is an important factor in the overall user experience. See the card component's <a href="http://www.google.com/design/spec/components/cards.html">Material Design specifications page</a> for details.</p> |
| 8 | <h3 id="to-include-an-mdl-card-component-">To include an MDL <strong>card</strong> component:</h3> |
| 9 | <p> 1. Code a <code><div></code> element; this is the "outer" container, intended to hold all of the card's content.</p> |
| 10 | <pre><code class="lang-html"><div> |
| 11 | </div> |
| 12 | </code></pre> |
| 13 | <p> 2. Inside the div, code one or more "inner" divs, one for each desired content block. A card containing a title, an image, some text, and an action bar would contain four "inner" divs, all siblings.</p> |
| 14 | <pre><code class="lang-html"><div> |
| 15 | <div> |
| 16 | ... |
| 17 | </div> |
| 18 | <div> |
| 19 | ... |
| 20 | </div> |
| 21 | <div> |
| 22 | ... |
| 23 | </div> |
| 24 | <div> |
| 25 | ... |
| 26 | </div> |
| 27 | </div> |
| 28 | </code></pre> |
| 29 | <p> 3. Add one or more MDL classes, separated by spaces, to the "outer" div and the "inner" divs (depending on their intended use) using the <code>class</code> attribute.</p> |
| 30 | <pre><code class="lang-html"><div class="mdl-card"> |
| 31 | <div class="mdl-card__title"> |
| 32 | ... |
| 33 | </div> |
| 34 | <div class="mdl-card__media"> |
| 35 | ... |
| 36 | </div> |
| 37 | <div class="mdl-card__supporting-text"> |
| 38 | ... |
| 39 | </div> |
| 40 | <div class="mdl-card__actions"> |
| 41 | ... |
| 42 | </div> |
| 43 | </div> |
| 44 | </code></pre> |
| 45 | <p> 4. Add content to each "inner" div, again depending on its intended use, using standard HTML elements and, optionally, additional MDL classes.</p> |
| 46 | <pre><code class="lang-html"><div class="mdl-card"> |
| 47 | <div class="mdl-card__title"> |
| 48 | <h2 class="mdl-card__title-text">title Text Goes Here</h2> |
| 49 | </div> |
| 50 | <div class="mdl-card__media"> |
| 51 | <img src="photo.jpg" width="220" height="140" border="0" alt="" style="padding:20px;"> |
| 52 | </div> |
| 53 | <div class="mdl-card__supporting-text"> |
| 54 | This text might describe the photo and provide further information, such as where and |
| 55 | when it was taken. |
| 56 | </div> |
| 57 | <div class="mdl-card__actions"> |
| 58 | <a href="(URL or function)">Related Action</a> |
| 59 | </div> |
| 60 | </div> |
| 61 | </code></pre> |
| 62 | <p>The card component is ready for use.</p> |
| 63 | <h4 id="examples">Examples</h4> |
| 64 | <p>A card (no shadow) with a title, image, text, and action.</p> |
| 65 | <pre><code class="lang-html"><div class="mdl-card"> |
| 66 | <div class="mdl-card__title"> |
| 67 | <h2 class="mdl-card__title-text">Auckland Sky Tower<br>Auckland, New Zealand</h2> |
| 68 | </div> |
| 69 | <div class="mdl-card__media"> |
| 70 | <img src="skytower.jpg" width="173" height="157" border="0" alt="" |
| 71 | style="padding:10px;"> |
| 72 | </div> |
| 73 | <div class="mdl-card__supporting-text"> |
| 74 | The Sky Tower is an observation and telecommunications tower located in Auckland, |
| 75 | New Zealand. It is 328 metres (1,076 ft) tall, making it the tallest man-made structure |
| 76 | in the Southern Hemisphere. |
| 77 | </div> |
| 78 | <div class="mdl-card__actions"> |
| 79 | <a href="http://en.wikipedia.org/wiki/Sky_Tower_%28Auckland%29">Wikipedia entry</a> |
| 80 | </div> |
| 81 | </div> |
| 82 | </code></pre> |
| 83 | <p>Card (level-3 shadow) with an image, caption, and text:</p> |
| 84 | <pre><code class="lang-html"><div class="mdl-card mdl-shadow--4dp"> |
| 85 | <div class="mdl-card__media"><img src="skytower.jpg" width="173" height="157" border="0" |
| 86 | alt="" style="padding:10px;"> |
| 87 | </div> |
| 88 | <div class="mdl-card__supporting-text"> |
| 89 | Auckland Sky Tower, taken March 24th, 2014 |
| 90 | </div> |
| 91 | <div class="mdl-card__supporting-text"> |
| 92 | The Sky Tower is an observation and telecommunications tower located in Auckland, |
| 93 | New Zealand. It is 328 metres (1,076 ft) tall, making it the tallest man-made structure |
| 94 | in the Southern Hemisphere. |
| 95 | </div> |
| 96 | </div> |
| 97 | </code></pre> |
| 98 | <h2 id="configuration-options">Configuration options</h2> |
| 99 | <p>The MDL CSS classes apply various predefined visual and behavioral enhancements to the card. The table below lists the available classes and their effects.</p> |
| 100 | <table> |
| 101 | <thead> |
| 102 | <tr> |
| 103 | <th>MDL class</th> |
| 104 | <th>Effect</th> |
| 105 | <th>Remarks</th> |
| 106 | </tr> |
| 107 | </thead> |
| 108 | <tbody> |
| 109 | <tr> |
| 110 | <td><code>mdl-card</code></td> |
| 111 | <td>Defines div element as an MDL card container</td> |
| 112 | <td>Required on "outer" div</td> |
| 113 | </tr> |
| 114 | <tr> |
| 115 | <td><code>mdl-card--border</code></td> |
| 116 | <td>Adds a border to the card section that it's applied to</td> |
| 117 | <td>Used on the "inner" divs</td> |
| 118 | </tr> |
| 119 | <tr> |
| 120 | <td><code>mdl-shadow--2dp through mdl-shadow--16dp</code></td> |
| 121 | <td>Assigns variable shadow depths (2, 3, 4, 6, 8, or 16) to card</td> |
| 122 | <td>Optional, goes on "outer" div; if omitted, no shadow is present</td> |
| 123 | </tr> |
| 124 | <tr> |
| 125 | <td><code>mdl-card__title</code></td> |
| 126 | <td>Defines div as a card title container</td> |
| 127 | <td>Required on "inner" title div</td> |
| 128 | </tr> |
| 129 | <tr> |
| 130 | <td><code>mdl-card__title-text</code></td> |
| 131 | <td>Assigns appropriate text characteristics to card title</td> |
| 132 | <td>Required on head tag (H1 - H6) inside title div</td> |
| 133 | </tr> |
| 134 | <tr> |
| 135 | <td><code>mdl-card__subtitle-text</code></td> |
| 136 | <td>Assigns text characteristics to a card subtitle</td> |
| 137 | <td>Optional. Should be a child of the title element.</td> |
| 138 | </tr> |
| 139 | <tr> |
| 140 | <td><code>mdl-card__media</code></td> |
| 141 | <td>Defines div as a card media container</td> |
| 142 | <td>Required on "inner" media div</td> |
| 143 | </tr> |
| 144 | <tr> |
| 145 | <td><code>mdl-card__supporting-text</code></td> |
| 146 | <td>Defines div as a card body text container and assigns appropriate text characteristics to body text</td> |
| 147 | <td>Required on "inner" body text div; text goes directly inside the div with no intervening containers</td> |
| 148 | </tr> |
| 149 | <tr> |
| 150 | <td><code>mdl-card__actions</code></td> |
| 151 | <td>Defines div as a card actions container and assigns appropriate text characteristics to actions text</td> |
| 152 | <td>Required on "inner" actions div; content goes directly inside the div with no intervening containers</td> |
| 153 | </tr> |
| 154 | <tr> |
| 155 | <td><code>mdl-card__menu</code></td> |
| 156 | <td>Defines element as top right menu button</td> |
| 157 | <td>Optional. Should be a child of the <code>mdl-card</code> element.</td> |
| 158 | </tr> |
| 159 | </tbody> |
| 160 | </table> |
| 161 | |
| 162 | |