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=
"../paper-ripple/paper-ripple.html">
13 <link rel=
"import" href=
"../paper-styles/default-theme.html">
14 <link rel=
"import" href=
"../paper-behaviors/paper-inky-focus-behavior.html">
18 `paper-checkbox` is a button that can be either checked or unchecked. User
19 can tap the checkbox to check or uncheck it. Usually you use checkboxes
20 to allow user to select multiple options from a set. If you have a single
21 ON/OFF option, avoid using a single checkbox and use `paper-toggle-button`
26 <paper-checkbox>label</paper-checkbox>
28 <paper-checkbox checked> label</paper-checkbox>
32 The following custom properties and mixins are available for styling:
34 Custom property | Description | Default
35 ----------------|-------------|----------
36 `--paper-checkbox-unchecked-background-color` | Checkbox background color when the input is not checked | `transparent`
37 `--paper-checkbox-unchecked-color` | Checkbox border color when the input is not checked | `--primary-text-color`
38 `--paper-checkbox-unchecked-ink-color` | Selected/focus ripple color when the input is not checked | `--primary-text-color`
39 `--paper-checkbox-checked-color` | Checkbox color when the input is checked | `--default-primary-color`
40 `--paper-checkbox-checked-ink-color` | Selected/focus ripple color when the input is checked | `--default-primary-color`
41 `--paper-checkbox-checkmark-color` | Checkmark color | `white`
42 `--paper-checkbox-label-color` | Label color | `--primary-text-color`
47 <dom-module id=
"paper-checkbox">
48 <link rel=
"import" type=
"css" href=
"paper-checkbox.css">
52 <div id=
"checkboxContainer">
53 <paper-ripple id=
"ink" class=
"circle" center checked$=
"[[checked]]"></paper-ripple>
54 <div id=
"checkbox" class$=
"[[_computeCheckboxClass(checked)]]">
55 <div id=
"checkmark" class$=
"[[_computeCheckmarkClass(checked)]]"></div>
59 <div id=
"checkboxLabel" aria-hidden=
"true"><content></content></div>
68 Polymer
.PaperInkyFocusBehavior
73 'aria-checked': false,
79 * Fired when the checked state changes due to user interaction.
85 * Fired when the checked state changes.
91 * Gets or sets the state, `true` is checked and `false` is unchecked.
96 reflectToAttribute
: true,
98 observer
: '_checkedChanged'
102 * If true, the button toggles the active state with each tap or press
108 reflectToAttribute
: true
113 if (Polymer
.dom(this).textContent
== '') {
114 this.$.checkboxLabel
.hidden
= true;
116 this.setAttribute('aria-label', Polymer
.dom(this).textContent
);
118 this._isReady
= true;
121 // button-behavior hook
122 _buttonStateChanged: function() {
127 this.checked
= this.active
;
131 _checkedChanged: function(checked
) {
132 this.setAttribute('aria-checked', this.checked
? 'true' : 'false');
133 this.active
= this.checked
;
134 this.fire('iron-change');
137 _computeCheckboxClass: function(checked
) {
144 _computeCheckmarkClass: function(checked
) {