3
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
Code distributed by Google as part of the polymer project is also
8
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
11
<link rel="import" href="../polymer/polymer.html">
12
<link rel="import" href="../iron-icon/iron-icon.html">
13
<link rel="import" href="../paper-behaviors/paper-inky-focus-behavior.html">
14
<link rel="import" href="../paper-styles/default-theme.html">
17
Material design: [Icon toggles](https://www.google.com/design/spec/components/buttons.html#buttons-toggle-buttons)
19
`paper-icon-button` is a button with an image placed at the center. When the user touches
20
the button, a ripple effect emanates from the center of the button.
22
`paper-icon-button` includes a default icon set. Use `icon` to specify which icon
23
from the icon set to use.
25
<paper-icon-button icon="menu"></paper-icon-button>
27
See [`iron-iconset`](iron-iconset) for more information about
28
how to use a custom icon set.
32
<link href="path/to/iron-icons/iron-icons.html" rel="import">
34
<paper-icon-button icon="favorite"></paper-icon-button>
35
<paper-icon-button src="star.png"></paper-icon-button>
37
To use `paper-icon-button` as a link, wrap it in an anchor tag. Since `paper-icon-button`
38
will already receive focus, you may want to prevent the anchor tag from receiving focus
39
as well by setting its tabindex to -1.
41
<a href="https://www.polymer-project.org" tabindex="-1">
42
<paper-icon-button icon="polymer"></paper-icon-button>
47
Style the button with CSS as you would a normal DOM element. If you are using the icons
48
provided by `iron-icons`, they will inherit the foreground color of the button.
50
/* make a red "favorite" button */
51
<paper-icon-button icon="favorite" style="color: red;"></paper-icon-button>
53
By default, the ripple is the same color as the foreground at 25% opacity. You may
54
customize the color using the `--paper-icon-button-ink-color` custom property.
56
The following custom properties and mixins are available for styling:
58
Custom property | Description | Default
59
----------------|-------------|----------
60
`--paper-icon-button-disabled-text` | The color of the disabled button | `--disabled-text-color`
61
`--paper-icon-button-ink-color` | Selected/focus ripple color | `--primary-text-color`
62
`--paper-icon-button` | Mixin for a button | `{}`
63
`--paper-icon-button-disabled` | Mixin for a disabled button | `{}`
64
`--paper-icon-button-hover` | Mixin for button on hover | `{}`
67
@element paper-icon-button
71
<dom-module id="paper-icon-button">
72
<template strip-whitespace>
75
display: inline-block;
79
-webkit-tap-highlight-color: rgba(0,0,0,0);
80
-webkit-user-select: none;
81
-moz-user-select: none;
82
-ms-user-select: none;
91
/* Because of polymer/2558, this style has lower specificity than * */
92
box-sizing: border-box !important;
94
@apply(--paper-icon-button);
98
color: var(--paper-icon-button-ink-color, --primary-text-color);
103
color: var(--paper-icon-button-disabled-text, --disabled-text-color);
104
pointer-events: none;
107
@apply(--paper-icon-button-disabled);
111
@apply(--paper-icon-button-hover);
115
--iron-icon-width: 100%;
116
--iron-icon-height: 100%;
120
<iron-icon id="icon" src="[[src]]" icon="[[icon]]" alt$="[[alt]]"></iron-icon>
125
is: 'paper-icon-button',
133
Polymer.PaperInkyFocusBehavior
138
* The URL of an image for the icon. If the src property is specified,
139
* the icon property should not be.
146
* Specifies the icon name or index in the set of icons available in
147
* the icon's icon set. If the icon property is specified,
148
* the src property should not be.
155
* Specifies the alternate text for the button, for accessibility.
159
observer: "_altChanged"
163
_altChanged: function(newValue, oldValue) {
164
var label = this.getAttribute('aria-label');
166
// Don't stomp over a user-set aria-label.
167
if (!label || oldValue == label) {
168
this.setAttribute('aria-label', newValue);