Material design: Chips.
A chip web component made with Polymer 3 following Material Design guidelines
This elements family may provide a icon or a photo, some line of text or a contact information with Material Design styling.
Table of contents
A minimal chip.
Single or multi-line
It can show single-line or multi-line text.
You can open a multi-line chip tapping on it, showing some additional info.
Following snippet of code shows how to configure (via attributes) some basic behavior.
It may be removable or not.
Do you want to animated the chip when it is opening?
You can do it via attribute.
<paper-chip-input> when you desire an input field where the strings digited by the user are collected as
How to configure its presentation
paper-chip-input presentation using attribute.
Disable the input underline
If you do not want the input underline use
How to fix the input label at the top
always-float-label attribute to fix the the label at the top.
Non floating label
no-label-float attribute to disable floating label. So the input label will be inside the input.
Input field feature
Inputs can have different types, and be disabled.
Inputs can have character counters.
Or you can limit chip text's max length.
Inputs can validate automatically or on demand, and can have custom error messages.
You can configure your favorite allowed pattern.
You can run validation manually
paper-chip-input can have custom prefix and suffix.
Chip-added and chip-removed event
paper-chip-input fires custom events chip-added/chip-removed event when a chip is added or removed to
Configure your favorite submit keys
Do you want to change the keys that automatically submit chips?
No worries, we support it!
Configure them with the
enter-keys property adding the keys.
We support the Polymer.IronA11yKeysBehavior format.
Following example should clarify the usage of this feature.
Do you need autocomplete ?
When you have a predefined and finite set of input values you can set the predefined values with
datasource property. Don't forget to add the
Configure custom datasource properties
The default properties for datasource are
value, but you can configure it from outside by the properties
Custom filter logic
Autocomplete uses a startWith filter as default logic.
Do you need to implement a custom filter logic? You can do it!
filter property with your custom function. The following lines of code will show you how to do it.
How to insert chips
You can insert
<paper-chip> elements inside the
<paper-chip-input> declaratively - ie., putting the within the Light DOM.
The following custom properties and mixins are available for styling:
||The paper-chip label-color||
||The paper-chip background-color||
||The paper-chip avatar background-color||
||The paper-chip icon color||
||The paper-chip label max-width when is closed||80px|
If you are using polyserve navigate to the
test/ directory of your element to run its tests.
You can view results in the browser console.
The tests are run via web-component-tester.
To run them locally execute:
Thanks for your interest in this project!
We are really glad you are reading this. External contributions are very welcome by our team. We know that we need volunteer developers to help this project come (and mantain) to fruition.
There are many ways to contribute to this project. Get started reading the contributing guide.
MIT © fabbricadigitale