|
| 1 | +<!DOCTYPE html> |
| 2 | +<!-- |
| 3 | + Copyright 2018 Google Inc. All rights reserved. |
| 4 | +
|
| 5 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + you may not use this file except in compliance with the License. |
| 7 | + You may obtain a copy of the License at |
| 8 | +
|
| 9 | + https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | + Unless required by applicable law or agreed to in writing, software |
| 12 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + See the License for the specific language governing permissions and |
| 15 | + limitations under the License |
| 16 | +--> |
| 17 | +<html> |
| 18 | + <head> |
| 19 | + <meta charset="utf-8"> |
| 20 | + <title>Icon Button - Material Components Demo</title> |
| 21 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 22 | + <link rel="icon" type="image/png" href="/images/logo_components_color_2x_web_48dp.png"> |
| 23 | + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono"> |
| 24 | + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> |
| 25 | + <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> |
| 26 | + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css"> |
| 27 | + <link rel="stylesheet" href="/assets/icon-button.css"> |
| 28 | + <script src="/ready.js"></script> |
| 29 | + </head> |
| 30 | + <body class="mdc-typography"> |
| 31 | + <header class="mdc-toolbar mdc-toolbar--fixed"> |
| 32 | + <div class="mdc-toolbar__row"> |
| 33 | + <section class="mdc-toolbar__section mdc-toolbar__section--align-start"> |
| 34 | + <a href="/" class="catalog-back mdc-toolbar__menu-icon"><i class="material-icons"></i></a> |
| 35 | + <span class="mdc-toolbar__title catalog-title">Icon Buttons</span> |
| 36 | + </section> |
| 37 | + </div> |
| 38 | + </header> |
| 39 | + <main> |
| 40 | + <div class="mdc-toolbar-fixed-adjust"></div> |
| 41 | + <section class="hero"> |
| 42 | + <div class="demo-wrapper"> |
| 43 | + <button class="mdc-icon-button material-icons" |
| 44 | + aria-label="Add to favorites" |
| 45 | + aria-pressed="false" |
| 46 | + data-demo-toggle |
| 47 | + data-toggle-on-content="favorite" |
| 48 | + data-toggle-on-label="Remove From Favorites" |
| 49 | + data-toggle-off-content="favorite_border" |
| 50 | + data-toggle-off-label="Add to Favorites">favorite_border</button> |
| 51 | + </div> |
| 52 | + </section> |
| 53 | + |
| 54 | + <section class="example"> |
| 55 | + <div> |
| 56 | + <div> |
| 57 | + <h1 class="mdc-typography--headline5">Buttons</h1> |
| 58 | + </div> |
| 59 | + <div class="toggle-examples-container"> |
| 60 | + <div class="toggle-example"> |
| 61 | + <h2 class="mdc-typography--headline6">Material Icons</h2> |
| 62 | + <div class="demo-wrapper"> |
| 63 | + <button class="mdc-icon-button material-icons" |
| 64 | + role="button" |
| 65 | + aria-label="Add to favorites" |
| 66 | + aria-pressed="false">favorite</button> |
| 67 | + <button class="mdc-icon-button material-icons" |
| 68 | + aria-label="Airplane Mode active" |
| 69 | + aria-pressed="false">airplanemode_active</button> |
| 70 | + <a href="#" |
| 71 | + class="mdc-icon-button material-icons" |
| 72 | + aria-label="Transit directions" |
| 73 | + aria-pressed="false">directions_transit</a> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + |
| 77 | + <div class="toggle-example"> |
| 78 | + <h2 class="mdc-typography--headline6">SVG Icon</h2> |
| 79 | + <div class="demo-wrapper"> |
| 80 | + <button class="mdc-icon-button" |
| 81 | + aria-label="Add to favorites" |
| 82 | + aria-pressed="false"> |
| 83 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> |
| 84 | + <path fill="none" d="M0 0h24v24H0z"/> |
| 85 | + <path d="M23 12c0-6.07-4.93-11-11-11S1 5.93 1 12s4.93 11 11 11 11-4.93 11-11zM5 17.64C3.75 16.1 3 14.14 3 12c0-2.13.76-4.08 2-5.63v11.27zM17.64 5H6.36C7.9 3.75 9.86 3 12 3s4.1.75 5.64 2zM12 14.53L8.24 7h7.53L12 14.53zM17 9v8h-4l4-8zm-6 8H7V9l4 8zm6.64 2c-1.55 1.25-3.51 2-5.64 2s-4.1-.75-5.64-2h11.28zM21 12c0 2.14-.75 4.1-2 5.64V6.37c1.24 1.55 2 3.5 2 5.63z"/> |
| 86 | + </svg> |
| 87 | + </button> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + |
| 91 | + <div class="toggle-example"> |
| 92 | + <h2 class="mdc-typography--headline6">Disabled Buttons</h2> |
| 93 | + <div class="demo-wrapper"> |
| 94 | + <button class="mdc-icon-button material-icons" |
| 95 | + aria-label="Airplane Mode active" |
| 96 | + aria-pressed="false" |
| 97 | + disabled>airplanemode_active</button> |
| 98 | + <button class="mdc-icon-button" |
| 99 | + aria-label="Add to favorites" |
| 100 | + aria-pressed="false" |
| 101 | + disabled> |
| 102 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> |
| 103 | + <path fill="none" d="M0 0h24v24H0z"/> |
| 104 | + <path d="M23 12c0-6.07-4.93-11-11-11S1 5.93 1 12s4.93 11 11 11 11-4.93 11-11zM5 17.64C3.75 16.1 3 14.14 3 12c0-2.13.76-4.08 2-5.63v11.27zM17.64 5H6.36C7.9 3.75 9.86 3 12 3s4.1.75 5.64 2zM12 14.53L8.24 7h7.53L12 14.53zM17 9v8h-4l4-8zm-6 8H7V9l4 8zm6.64 2c-1.55 1.25-3.51 2-5.64 2s-4.1-.75-5.64-2h11.28zM21 12c0 2.14-.75 4.1-2 5.64V6.37c1.24 1.55 2 3.5 2 5.63z"/> |
| 105 | + </svg> |
| 106 | + </button> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + |
| 110 | + <div class="toggle-example"> |
| 111 | + <h2 class="mdc-typography--headline6">Larger Buttons</h2> |
| 112 | + <div class="demo-wrapper"> |
| 113 | + <button class="mdc-icon-button material-icons demo-icon-button-large" |
| 114 | + aria-label="Airplane Mode active" |
| 115 | + aria-pressed="false">airplanemode_active</button> |
| 116 | + <button class="mdc-icon-button demo-icon-button-large" |
| 117 | + aria-label="Add to favorites" |
| 118 | + aria-pressed="false"> |
| 119 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> |
| 120 | + <path fill="none" d="M0 0h24v24H0z"/> |
| 121 | + <path d="M23 12c0-6.07-4.93-11-11-11S1 5.93 1 12s4.93 11 11 11 11-4.93 11-11zM5 17.64C3.75 16.1 3 14.14 3 12c0-2.13.76-4.08 2-5.63v11.27zM17.64 5H6.36C7.9 3.75 9.86 3 12 3s4.1.75 5.64 2zM12 14.53L8.24 7h7.53L12 14.53zM17 9v8h-4l4-8zm-6 8H7V9l4 8zm6.64 2c-1.55 1.25-3.51 2-5.64 2s-4.1-.75-5.64-2h11.28zM21 12c0 2.14-.75 4.1-2 5.64V6.37c1.24 1.55 2 3.5 2 5.63z"/> |
| 122 | + </svg> |
| 123 | + </button> |
| 124 | + </div> |
| 125 | + </div> |
| 126 | + </div> |
| 127 | + </div> |
| 128 | + </section> |
| 129 | + |
| 130 | + <section class="example"> |
| 131 | + <div> |
| 132 | + <div> |
| 133 | + <h1 class="mdc-typography--headline5">Button Toggles</h1> |
| 134 | + </div> |
| 135 | + <div class="toggle-examples-container"> |
| 136 | + <div class="toggle-example"> |
| 137 | + <h2 class="mdc-typography--headline6">Using Material Icons</h2> |
| 138 | + <div class="demo-wrapper"> |
| 139 | + <button |
| 140 | + id="add-to-favorites" |
| 141 | + class="mdc-icon-button material-icons" |
| 142 | + aria-label="Add to favorites" |
| 143 | + aria-pressed="false" |
| 144 | + data-demo-toggle |
| 145 | + data-toggle-on-content="favorite" |
| 146 | + data-toggle-on-label="Remove From Favorites" |
| 147 | + data-toggle-off-content="favorite_border" |
| 148 | + data-toggle-off-label="Add to Favorites">favorite_border</button> |
| 149 | + </div> |
| 150 | + <p>Favorited? <span id="favorited-status">no</span></p> |
| 151 | + </div> |
| 152 | + |
| 153 | + <div class="toggle-example"> |
| 154 | + <h2 class="mdc-typography--headline6">Using Font Awesome</h2> |
| 155 | + <div class="demo-wrapper"> |
| 156 | + <button class="mdc-icon-button mdc-icon-button--on" |
| 157 | + aria-label="Unstar this item" |
| 158 | + aria-pressed="true" data-demo-toggle |
| 159 | + data-icon-inner-selector=".fa" |
| 160 | + data-toggle-on-class="fa-star" |
| 161 | + data-toggle-on-label="Unstar this item" |
| 162 | + data-toggle-off-class="fa-star-o" |
| 163 | + data-toggle-off-label="Star this item"> |
| 164 | + <i class="fa fa-star" aria-hidden="true"></i> |
| 165 | + </button> |
| 166 | + </div> |
| 167 | + </div> |
| 168 | + |
| 169 | + <div class="toggle-example"> |
| 170 | + <h2 class="mdc-typography--headline6">Disabled Icons</h2> |
| 171 | + <div class="demo-wrapper"> |
| 172 | + <button class="mdc-icon-button material-icons" |
| 173 | + aria-label="Add to favorites" |
| 174 | + aria-pressed="false" |
| 175 | + data-demo-toggle |
| 176 | + disabled |
| 177 | + data-toggle-on-content="favorite" |
| 178 | + data-toggle-on-label="Remove From Favorites" |
| 179 | + data-toggle-off-content="favorite_border" |
| 180 | + data-toggle-off-label="Add to Favorites">favorite_border</button> |
| 181 | + </div> |
| 182 | + </div> |
| 183 | + </div> |
| 184 | + |
| 185 | + <div class="toggle-example"> |
| 186 | + <h2 class="mdc-typography--headline6">Additional Color Combinations</h2> |
| 187 | + <div id="demo-color-combos"> |
| 188 | + <div id="light-on-bg" class="demo-color-combo"> |
| 189 | + <div> |
| 190 | + <button class="mdc-icon-button material-icons mdc-theme--on-primary" |
| 191 | + aria-label="Add to favorites" |
| 192 | + aria-pressed="false" |
| 193 | + data-demo-toggle |
| 194 | + data-toggle-on-content="favorite" |
| 195 | + data-toggle-on-label="Remove From Favorites" |
| 196 | + data-toggle-off-content="favorite_border" |
| 197 | + data-toggle-off-label="Add to Favorites">favorite_border</button> |
| 198 | + </div> |
| 199 | + <div class="mdc-theme--on-primary">Light icon on background</div> |
| 200 | + </div> |
| 201 | + <div id="dark-on-bg" class="demo-color-combo"> |
| 202 | + <div class="mdc-theme--primary"> |
| 203 | + <button class="mdc-icon-button material-icons" |
| 204 | + aria-label="Add to favorites" |
| 205 | + aria-pressed="false" |
| 206 | + data-demo-toggle |
| 207 | + data-toggle-on-content="favorite" |
| 208 | + data-toggle-on-label="Remove From Favorites" |
| 209 | + data-toggle-off-content="favorite_border" |
| 210 | + data-toggle-off-label="Add to Favorites">favorite_border</button> |
| 211 | + </div> |
| 212 | + <div>Dark icon on background</div> |
| 213 | + </div> |
| 214 | + <div id="custom-color-combo" class="demo-color-combo"> |
| 215 | + <div> |
| 216 | + <button class="mdc-icon-button material-icons" |
| 217 | + aria-label="Add to favorites" |
| 218 | + aria-pressed="false" |
| 219 | + data-demo-toggle |
| 220 | + data-toggle-on-content="favorite" |
| 221 | + data-toggle-on-label="Remove From Favorites" |
| 222 | + data-toggle-off-content="favorite_border" |
| 223 | + data-toggle-off-label="Add to Favorites">favorite_border</button> |
| 224 | + </div> |
| 225 | + <div>Custom color</div> |
| 226 | + </div> |
| 227 | + </div> |
| 228 | + </div> |
| 229 | + </div> |
| 230 | + </section> |
| 231 | + </main> |
| 232 | + |
| 233 | + <script src="/assets/material-components-web.js" async></script> |
| 234 | + <script src="/assets/common.js" async></script> |
| 235 | + <script> |
| 236 | + demoReady(function() { |
| 237 | + var nodes = document.querySelectorAll('[data-demo-toggle]'); |
| 238 | + for (var i = 0, node; node = nodes[i]; i++) { |
| 239 | + mdc.iconButton.MDCIconButtonToggle.attachTo(node); |
| 240 | + } |
| 241 | + |
| 242 | + var buttons = document.querySelectorAll('.mdc-icon-button:not([data-demo-toggle])'); |
| 243 | + for (var x = 0, button; button = buttons[x]; x++) { |
| 244 | + mdc.ripple.MDCRipple.attachTo(button, {isUnbounded: true}); |
| 245 | + } |
| 246 | + |
| 247 | + var addToFavorites = document.getElementById('add-to-favorites'); |
| 248 | + var favoritedStatus = document.getElementById('favorited-status'); |
| 249 | + addToFavorites.addEventListener('MDCIconButtonToggle:change', function(evt) { |
| 250 | + var newStatus = evt.detail.isOn ? 'yes' : 'no'; |
| 251 | + favoritedStatus.textContent = newStatus; |
| 252 | + }); |
| 253 | + }); |
| 254 | + </script> |
| 255 | + </body> |
| 256 | +</html> |
0 commit comments