3.0.2 • Public • Published

Published on NPM Published on webcomponents.org Published on Vaadin  Directory

API & Demo


What is it for?

color-picker is a picker for color for Polymer that can use the native input, too. It has the same approach like in <datetime-picker>. If the native picker is choosen and is not supported, this element use the polyfill color-picker. The <color-element> will come in place if the native picker is not available or is not explicitly wanted. The value and color-string will give you directly the css-string in the selected format.


Internally it tests the browser, if native input-type color is supported. You can decide to use the native or the replacements during runtime. color-element can also be used separately. By default, the polyfilled version is used.

It might be useful for you to use, if you like to keep the native approach of Browsers on Mobile Devices, or you like to have a different look or you would like to have a guaranteed working color-picker. Another use case could be for example, if you want on mobile devices use the native picker, when supported, and on desktop devices this polyfill.

For that purposes the attributes native and native-on-mobile are provided.

  <datetime-picker native></datetime-picker>
  <datetime-picker native-on-mobile></datetime-picker>


The component page explains, which of the attributes you can use and how. You can see there a demo, too.



<color-picker r="{{r}}" g="{{g}}" b="{{b}}" default="green" native="[[native]]" auto-confirm="[[autoConfirm]]"></color-picker>  
  <span> red: [[r]] </span>
  <span> green: [[g]] </span>
  <span> blue: [[b]] </span>  
  <input type="checkbox" checked="{{native::change}}">native color picker
  <input type="checkbox" checked="{{autoConfirm::change}}">auto confirm

Stand-alone color-element

  <color-element alpha="{{alpha}}" r="{{r}}" g="{{g}}" b="{{b}}" h="{{h}}" s="{{s}}" l="{{l}}" format="{{format}}"></color-element><br>
    <span>format </span>
    <select id="formats" value="{{format::change}}">
      <option value="auto">auto</option>
      <option value="rgb">rgb</option>
      <option value="hex">hex</option>
      <option value="hsl">hsl</option>
    <input type="range" min="0" max="1" step="0.01" value="{{alpha::change}}"><span> alpha: [[alpha]] </span>
    <input type="range" min="0" max="255" step="1" value="{{r::input}}"><span> red: [[r]] </span>
    <input type="range" min="0" max="255" step="1" value="{{g::input}}"><span> green: [[g]] </span>
    <input type="range" min="0" max="255" step="1" value="{{b::input}}"><span> blue: [[b]] </span>
    <input type="range" min="0" max="359" step="1" value="{{h::input}}"><span> hue: [[h]] </span>
    <input type="range" min="0" max="1" step="0.001" value="{{s::input}}"><span> saturation: [[s]] </span>
    <input type="range" min="0" max="1" step="0.001" value="{{l::input}}"><span> lightness: [[l]] </span>

Use the polyfill or the native picker

By default it checks if color is supported for a native input. If it is not and you have set native, the polyfill will be used instead of the native input. Additionally there is the attribute native-on-mobile.


Have a look at input-picker-pattern#input-shared-style to see how to style the element.


npm install --save @fooloomanzoo/color-picker


Feel free to send a new issue, a commit, a pull request or just fork it!

Package Sidebar


npm i @fooloomanzoo/color-picker

Weekly Downloads






Unpacked Size

1.27 MB

Total Files


Last publish


  • fooloomanzoo