iron-input | Vaadin

An input with data binding

Published on NPM Build status Published on


<iron-input> adds two-way binding and custom validators using Polymer.IronValidatorBehavior to <input>.

See: Documentation, Demo.



npm install --save @polymer/iron-input

In an html file

    <script type="module">
      import '@polymer/iron-input/iron-input.js';

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@polymer/iron-input/iron-input.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
customElements.define('sample-element', SampleElement);

Two-way binding

By default you can only get notified of changes to an input's value due to user input:

<input value="{{myValue::input}}">

iron-input adds the bind-value property that mirrors the value property, and can be used for two-way data binding. bind-value will notify if it is changed either by user input or by script.

<iron-input bind-value="{{bindValue}}">
  <input value="{{value::input}}">

Custom validators

You can use custom validators that implement Polymer.IronValidatorBehavior with <iron-input>.

<iron-input auto-validate validator="my-custom-validator">
  <input placeholder="only 'cat' is valid">

Stopping invalid input

It may be desirable to only allow users to enter certain characters. You can use the prevent-invalid-input and allowed-pattern attributes together to accomplish this. This feature is separate from validation, and allowed-pattern does not affect how the input is validated.

<!-- only allow characters that match [0-9] -->
<iron-input allowed-pattern="[0-9]">
  <input pattern="\d{5}">


If you want to send a PR to this element, here are the instructions for running the tests and demo locally:


git clone
cd iron-input
npm install
npm install -g polymer-cli

Running the demo locally

polymer serve --npm

Running the tests

polymer test --npm


Link to this version
ImportedReleased 03 May 2018Other
Framework Support
Polymer 2.0+
Also supported:
Polymer 1 (3.0.1)Polymer 3 (3.0.1)
Browser Compatibility
Install with
bower install --save PolymerElements/iron-input"#2.1.3"
Run the above Bower command in your project folder. If you have any issues installing, please contact the author.
Release notes - Version 2.1.3


  • iron-a11y-announcer#PolymerElements/iron-a11y-announcer#1 - 2
  • iron-validatable-behavior#PolymerElements/iron-validatable-behavior#1 - 2
  • polymer#Polymer/polymer#1.9 - 2