jQuery Colorpicker Plugin For Bootstrap

jQuery Colorpicker Plugin For Bootstrap
File Size: 63.3 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Colorpicker Plugin For Bootstrap allows you to add color picker to field or to any other element with multiple formats: hex, rgb, rgba, hsl, hsla.

You might also like:

How to use it:

1. Include jQuery script and bootstrap-colorpicker.js

<script src="js/jquery.js"></script>
<script src="js/bootstrap-colorpicker.js"></script>

2. Include CSS before </head>.

<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/colorpicker.css" rel="stylesheet">

3. Call the function on target element.

$('.colorpicker').colorpicker();

4. Default plugin options.

// horizontal mode layout ?
horizontal: false, 

// forces to show the colorpicker as an inline element
inline: false, 

// forces a color
color: false, 

// forces a format
format: false, 

// children input selector
input: 'input', 

// container selector
container: false, 

// children component selector
component: '.add-on, .input-group-addon', 

// Vertical sliders configuration
sliders: {
  saturation: {
    maxLeft: 100,
    maxTop: 100,
    callLeft: 'setSaturation',
    callTop: 'setBrightness'
  },
  hue: {
    maxLeft: 0,
    maxTop: 100,
    callLeft: false,
    callTop: 'setHue'
  },
  alpha: {
    maxLeft: 0,
    maxTop: 100,
    callLeft: false,
    callTop: 'setAlpha'
  }
},

// Horizontal sliders configuration
slidersHorz: {
  saturation: {
    maxLeft: 100,
    maxTop: 100,
    callLeft: 'setSaturation',
    callTop: 'setBrightness'
  },
  hue: {
    maxLeft: 100,
    maxTop: 0,
    callLeft: 'setHue',
    callTop: false
  },
  alpha: {
    maxLeft: 100,
    maxTop: 0,
    callLeft: 'setAlpha',
    callTop: false
  }
},

// Customizes the default colorpicker HTML template.
template: '<div class="colorpicker dropdown-menu">' +
  '<div class="colorpicker-saturation"><i><b></b></i></div>' +
  '<div class="colorpicker-hue"><i></i></div>' +
  '<div class="colorpicker-alpha"><i></i></div>' +
  '<div class="colorpicker-color"><div /></div>' +
  '<div class="colorpicker-selectors"></div>' +
  '</div>',

// By default, the colorpicker is aligned to the right of the input. 
// If you need to switch it to the left, set align to 'left'.
align: 'right',

//  Adds this class to the colorpicker widget.
customClass: null,
colorSelectors: null
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/colorpicker.css" rel="stylesheet">

Change Log:

2016-11-07

  • v2.3.6

2016-04-05

  • preventing hidePicker to be fired twice

2015-11-22

  • v2.3.0

This awesome jQuery plugin is developed by itsjavi. For more Advanced Usages, please check the demo page or visit the official website.