jQuery Colorpicker Plugin For Bootstrap

jQuery Colorpicker Plugin For Bootstrap
File Size: 98.5 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 Logs:

v2.5.1 (2017-02-06)

  • Fix colors not being displayed hexNumberSignPrefix=false

v2.4.0 (2016-12-29)

  • Bootstrap is no longer a bower dependency
  • Fixed some demos and updated docs with new options
  • Fixed color selectos display problem
  • Added some useful rules for visibility classes
  • Is now possible to initialize the plugin using another parent than main window
  • Fixed cancellation of input change event and colorpicker child element events
  • New options for setting the fallback color and format (before it was always black and hex)
  • Fixed click/tap on mobile devices
  • Other UI fixes and improvements (like saturation disappearing)

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 farbelous. For more Advanced Usages, please check the demo page or visit the official website.