Sleek HTML5 / Javascript Color Picker – iro.js

Category: Color , Javascript , Recommended | March 19, 2019
Author: jaames
Views Total: 5,505
Official Page: Go to website
Last Update: March 19, 2019
License: MIT


Sleek HTML5 / Javascript Color Picker – iro.js


iro.js is a sleek, HSV color based JavaScript color picker for generating a pretty, HTML5 canvas based color wheel UI with touch support.

Also provides API methods that allow you to set, update, convert between colors.


$ npm install @jaames/iro --save

How to use it:

Import the module.

import iro from "@jaames/iro";

Or add the core JavaScript library to the html page:

<script src="iro.min.js"></script>

Create a placeholder element for the color picker.

<div class="wheel" id="colorWheelDemo"></div>

Generate a basic color picker inside the container ‘colorWheelDemo’.

var colorWheel = iro.ColorPicker("#colorWheelDemo", {
    // options here

Possible options to customize your color picker.

var colorWheel = iro.ColorPicker("#colorWheelDemo", {
    width: 300,
    color: '#fff',
    padding: 6,
    borderWidth: 0,
    borderColor: '#fff',
    handleRadius: 8,
    handleSvg: null, // Custom handle SVG
    handleOrigin: {
      x: 0,
      y: 0
    wheelLightness: true,
    sliderHeight: undefined,
    sliderMargin: 12,
    display: 'block', // CSS display value
    layout: {} // Custom Layouts

Event handlers available.

colorWheel.on('color:change', function(color){
  // when the color has changed, the callback gets passed the color object and an object providing which color channels (out of H, S, V) have changed.

colorWheel.on('input:start', function(color){
  // when the user starts interacting with the color picker, the callback gets passed the color object

colorWheel.on('input:end', function(color){
  // when the user has finished interacting with the color picker, the callback gets passed the color object

colorWheel.on('mount', function(color){
  // fired once the color picker UI has been mounted into the DOM

Useful API methods.

// sets color

// sets color chanel
color.setChannel('rgb', 'r', 255);

// clones color

// converts HSV to RGB

// converts RGB to HSV

// converts HSV to HSL

// converts HSL to HSV


v4.2.1 (03/19/2019)

  • Fixes color picker DOM event handling in IE11

v4.2.0 (03/12/2019)

  • Internal plugin API changes to allow for plugins to customise the slider type
  • Adds support for hue and saturation sliders

v4.0.3 (03/07/2019)

  • add slider getValueFromPoint to make plugin dev a bit easier

v4.0.2 (03/02/2019)

  • fire color:change if registered before color picker was mounted

v4.0.0 (02/23/2019)

  • Custom SVG handles
  • Custom layout config options
  • Updated Plugin API
  • Code tests
  • Rewritten codebase, is now much cleaner
  • Color picker components are now built using preact
  • Rewritten documentaion and readme, which huge focus on making things easier to follow


  • v3.5.6: hotfix for svg url generation in older iOS webviews


  • v3.5.5: hotfix for hsl string parsing bug


  • v3.5.4: hotfix for black output on mobile and desktop Safari


  • v3.5.3: Fixed small issue with parent container size


  • v3.5.2: Improve workaround for broken gradient URLs in Safari


  • v3.5.0: Rewritten API classes using the es6 syntax


  • v3.4.3: fix touch scrolling intervention in chrome


  • v3.4.2: Fixes a warning caused by some recent Chrome changes


  • v3.4.1: Fixed rounding issues when converting between color models, particularly when converting certain colors from RGB hex -> HSL -> RGB hex.

You Might Be Interested In:

3 thoughts on “Sleek HTML5 / Javascript Color Picker – iro.js

  1. pablo79

    Thank you for this script.
    Is it possible to send three RGB values to a POST function for some php script?


Leave a Reply