2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
13 Material Design: <a href="http://www.google.com/design/spec/components/buttons.html">Button</a>
15 `paper-fab` is a floating action button. It contains an image placed in the center and
16 comes in two sizes: regular size and a smaller size by applying the attribute `mini`. When
17 the user touches the button, a ripple effect emanates from the center of the button.
19 You may import `core-icons` to use with this element, or provide an URL to a custom icon.
20 See `core-iconset` for more information about how to use a custom icon set.
24 <link href="path/to/core-icons/core-icons.html" rel="import">
26 <paper-fab icon="add"></paper-fab>
27 <paper-fab mini icon="favorite"></paper-fab>
28 <paper-fab src="star.png"></paper-fab>
33 Style the button with CSS as you would a normal DOM element. If you are using the icons
34 provided by `core-icons`, the icon will inherit the foreground color of the button.
36 /* make a blue "cloud" button */
37 <paper-fab icon="cloud" style="color: blue;"></paper-fab>
39 By default, the ripple is the same color as the foreground at 25% opacity. You may
40 customize the color using this selector:
42 /* make #my-button use a blue ripple instead of foreground color */
43 #my-button::shadow #ripple {
47 The opacity of the ripple is not customizable via CSS.
52 The button is accessible by default if you use the `icon` property. By default, the
53 `aria-label` attribute will be set to the `icon` property. If you use a custom icon,
54 you should ensure that the `aria-label` attribute is set.
56 <paper-fab src="star.png" aria-label="star"></paper-fab>
59 @extends paper-button-base
63 <link href=
"../polymer/polymer.html" rel=
"import">
64 <link href=
"../core-icon/core-icon.html" rel=
"import">
65 <link href=
"../paper-button/paper-button-base.html" rel=
"import">
66 <link href=
"../paper-ripple/paper-ripple.html" rel=
"import">
67 <link href=
"../paper-shadow/paper-shadow.html" rel=
"import">
69 <polymer-element name=
"paper-fab" extends=
"paper-button-base" attributes=
"src icon mini" role=
"button">
75 display: inline-block;
78 -webkit-user-select: none;
83 box-sizing: border-box;
100 pointer-events: none;
105 pointer-events: none;
110 border-radius: inherit;
111 pointer-events: none;
116 pointer-events: none;
120 <template if=
"{{raised}}">
121 <paper-shadow id=
"shadow" fit animated
></paper-shadow>
124 <!-- to position to ripple behind the icon -->
125 <core-icon relative
id=
"icon" src=
"{{src}}" icon=
"{{icon}}"></core-icon>
135 * The URL of an image for the icon. If the src property is specified,
136 * the icon property should not be.
145 * Specifies the icon name or index in the set of icons available in
146 * the icon's icon set. If the icon property is specified,
147 * the src property should not be.
156 * Set this to true to style this is a "mini" FAB.
165 recenteringTouch
: true,
170 iconChanged: function(oldIcon
) {
171 var label
= this.getAttribute('aria-label');
172 if (!label
|| label
=== oldIcon
) {
173 this.setAttribute('aria-label', this.icon
);