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
9 --><html><head><link rel=
"import" href=
"../polymer/polymer.html">
10 <link rel=
"import" href=
"../paper-styles/paper-styles.html">
13 `<paper-input-container>` is a container for a `<label>`, an `<input is="iron-input">` or
14 `<iron-autogrow-textarea>` and optional add-on elements such as an error message or character
15 counter, used to implement Material Design text fields.
19 <paper-input-container>
20 <label>Your name</label>
21 <input is="iron-input">
22 </paper-input-container>
24 ### Listening for input changes
26 By default, it listens for changes on the `bind-value` attribute on its children nodes and perform
27 tasks such as auto-validating and label styling when the `bind-value` changes. You can configure
28 the attribute it listens to with the `attr-for-value` attribute.
30 ### Using a custom input element
32 You can use a custom input element in a `<paper-input-container>`, for example to implement a
33 compound input field like a social security number input. The custom input element should have the
34 `paper-input-input` class, have a `notify:true` value property and optionally implements
35 `Polymer.IronValidatableBehavior` if it is validatble.
37 <paper-input-container attr-for-value="ssn-value">
38 <label>Social security number</label>
39 <ssn-input class="paper-input-input"></ssn-input>
40 </paper-input-container>
44 If the `auto-validate` attribute is set, the input container will validate the input and update
45 the container styling when the input value changes.
49 Add-ons are child elements of a `<paper-input-container>` with the `add-on` attribute and
50 implements the `Polymer.PaperInputAddonBehavior` behavior. They are notified when the input value
51 or validity changes, and may implement functionality such as error messages or character counters.
52 They appear at the bottom of the input.
56 The following custom properties and mixins are available for styling:
58 Custom property | Description | Default
59 ----------------|-------------|----------
60 `--paper-input-container-color` | Label and underline color when the input is not focused | `--secondary-text-color`
61 `--paper-input-container-focus-color` | Label and underline color when the input is focused | `--default-primary-color`
62 `--paper-input-container-invalid-color` | Label and underline color when the input is focused | `--google-red-500`
63 `--paper-input-container-input-color` | Input foreground color | `--primary-text-color`
64 `--paper-input-container` | Mixin applied to the container | `{}`
65 `--paper-input-container-label` | Mixin applied to the label | `{}`
66 `--paper-input-container-label-focus` | Mixin applied to the label when the input is focused | `{}`
67 `--paper-input-container-input` | Mixin applied to the input | `{}`
68 `--paper-input-container-underline` | Mixin applied to the underline | `{}`
69 `--paper-input-container-underline-focus` | Mixin applied to the underline when the input is focued | `{}`
70 `--paper-input-container-underline-disabled` | Mixin applied to the underline when the input is disabled | `{}`
72 This element is `display:block` by default, but you can set the `inline` attribute to make it
73 `display:inline-block`.
75 </head><body><dom-module id=
"paper-input-container">
83 @apply(--paper-input-container);
87 display: inline-block;
95 .floated-label-placeholder {
96 @apply(--paper-font-caption);
106 -webkit-transform-origin: center center;
107 transform-origin: center center;
108 -webkit-transform: scale3d(
0,
1,
1);
109 transform: scale3d(
0,
1,
1);
111 background: var(--paper-input-container-focus-color, --default-primary-color);
113 @apply(--paper-input-container-underline-focus);
116 .underline.is-highlighted .focused-line {
117 -webkit-transform: none;
119 -webkit-transition: -webkit-transform
0.25s;
120 transition: transform
0.25s;
122 @apply(--paper-transition-easing);
125 .underline.is-invalid .focused-line {
126 background: var(--paper-input-container-invalid-color, --google-red-
500);
128 -webkit-transform: none;
130 -webkit-transition: -webkit-transform
0.25s;
131 transition: transform
0.25s;
133 @apply(--paper-transition-easing);
138 background: var(--paper-input-container-color, --secondary-text-color);
140 @apply(--paper-input-container-underline);
143 :host([disabled]) .unfocused-line {
144 border-bottom:
1px dashed;
145 border-color: var(--paper-input-container-color, --secondary-text-color);
146 background: transparent;
148 @apply(--paper-input-container-underline-disabled);
155 .input-content ::content label,
156 .input-content ::content .paper-input-label {
162 color: var(--paper-input-container-color, --secondary-text-color);
164 @apply(--paper-font-subhead);
165 @apply(--paper-input-container-label);
168 .input-content.label-is-floating ::content label,
169 .input-content.label-is-floating ::content .paper-input-label {
170 -webkit-transform: translate3d(
0, -
75%,
0) scale(
0.75);
171 transform: translate3d(
0, -
75%,
0) scale(
0.75);
172 -webkit-transform-origin: left top;
173 transform-origin: left top;
174 -webkit-transition: -webkit-transform
0.25s;
175 transition: transform
0.25s;
177 @apply(--paper-transition-easing);
180 .input-content.label-is-highlighted ::content label,
181 .input-content.label-is-highlighted ::content .paper-input-label {
182 color: var(--paper-input-container-focus-color, --default-primary-color);
184 @apply(--paper-input-container-label-focus);
187 .input-content.is-invalid ::content label,
188 .input-content.is-invalid ::content .paper-input-label {
189 color: var(--paper-input-container-invalid-color, --google-red-
500);
192 .input-content.label-is-hidden ::content label,
193 .input-content.label-is-hidden ::content .paper-input-label {
197 .input-content ::content input,
198 .input-content ::content textarea,
199 .input-content ::content iron-autogrow-textarea,
200 .input-content ::content .paper-input-input {
201 position: relative; /* to make a stacking context */
206 background: transparent;
208 color: var(--paper-input-container-input-color, --primary-text-color);
210 @apply(--paper-font-subhead);
211 @apply(--paper-input-container-input);
214 /* Firefox sets a min-width on the input, which can cause layout issues */
215 .input-content ::content input {
219 .input-content ::content textarea {
223 .add-on-content.is-invalid ::content * {
224 color: var(--paper-input-container-invalid-color, --google-red-
500);
227 .add-on-content.is-highlighted ::content * {
228 color: var(--paper-input-container-focus-color, --default-primary-color);
235 <template is=
"dom-if" if=
"[[!noLabelFloat]]">
236 <div class=
"floated-label-placeholder"> </div>
239 <div class$=
"[[_computeInputContentClass(noLabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent)]]">
240 <content select=
":not([add-on])"></content>
243 <div class$=
"[[_computeUnderlineClass(focused,invalid)]]">
244 <div class=
"unfocused-line fit"></div>
245 <div class=
"focused-line fit"></div>
248 <div class$=
"[[_computeAddOnContentClass(focused,invalid)]]">
249 <content id=
"addOnContent" select=
"[add-on]"></content>
256 <script src=
"paper-input-container-extracted.js"></script></body></html>