Home

Awesome

<!--<a class="readme-logo" href="https://itsjavi.com/bootstrap-colorpicker"> <img alt="Logo by @reallinfo" src="logo.png" width="128px" /> </a>-->

Bootstrap Colorpicker

<!--version-->

Bootstrap Colorpicker is a modular color picker plugin for Bootstrap 4.

Build Status npm

THIS PROJECT IS NOT MAINTAINED ANYMORE. After almost 10 years, it won't receive any further update. I recommend you using more modern solutions like React Color. You are still free to adapt this project and create forks and variants of it.

Install

You can get the latest version in many different ways:

Note that the dist files are only distributed via the NPM and Yarn installations.

For the rest methods, you will need to generate the files initializing the project with yarn install and then building the code using npm run build.

Versions

<table class="table table-bordered table-striped"> <thead> <tr> <th>Colorpicker version</th> <th>Compatible Bootstrap version</th> <th>Dependencies</th> </tr> </thead> <tbody> <tr> <td> <a href="https://github.com/itsjavi/bootstrap-colorpicker/tree/v2.x">v2.x</a> <br> <a href="https://itsjavi.com/bootstrap-colorpicker/v2">Documentation</a> </td> <td>Bootstrap 3 or 4</td> <td> <ul> <li>jQuery >= 1.10</li> <li>Bootstrap CSS (input addon)</li> </ul> </td> </tr> <tr> <td> <a href="https://github.com/itsjavi/bootstrap-colorpicker">v3.x</a> <br> <a href="https://itsjavi.com/bootstrap-colorpicker">Documentation</a> </td> <td>Bootstrap 4 or without Bootstrap</td> <td> <ul> <li>jQuery >= 2.1.0</li> <li>Bootstrap CSS (input addon, popover)</li> <li>Bootstrap JS Bundle (popover)</li> </ul> </td> </tr> </thead> </table>

Note that the plugin may work without Bootstrap if your code is not using any of the mentioned Bootstrap dependencies.

Examples

With Bootstrap

The Bootstrap JS dependency is optional and it is mainly needed for the popover support. No Bootstrap CSS is required for the plugin to work.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link href="dist/css/bootstrap-colorpicker.css" rel="stylesheet">
</head>
<body>
  <div class="demo">
      <h1>Bootstrap Colorpicker Demo (with Bootstrap)</h1>
      <input id="demo-input" type="text" value="rgb(255, 128, 0)" />
  </div>
  <script src="//code.jquery.com/jquery-3.4.1.js"></script>
  <script src="//unpkg.com/bootstrap@4.3.1/dist/js/bootstrap.bundle.min.js"></script>
  <script src="dist/js/bootstrap-colorpicker.js"></script>
  <script>
    $(function () {
      // Basic instantiation:
      $('#demo-input').colorpicker();
      
      // Example using an event, to change the color of the #demo div background:
      $('#demo-input').on('colorpickerChange', function(event) {
        $('#demo').css('background-color', event.color.toString());
      });
    });
  </script>
</body>

Without Bootstrap

To use the plugin without Bootstrap, the popover option should be set to false or null and, depending on your implementation, you will usually need to set inline to true and a container selector option.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link href="dist/css/bootstrap-colorpicker.css" rel="stylesheet">
</head>
<body>
  <div id="demo">
      <h1>Bootstrap Colorpicker Demo (without Bootstrap)</h1>
    <input type="text" value="rgb(255, 128, 0)" />
  </div>
  <script src="//code.jquery.com/jquery-3.4.1.js"></script>
  <script src="dist/js/bootstrap-colorpicker.js"></script>
  <script>
    $(function() {
      $('#demo').colorpicker({
        popover: false,
        inline: true,
        container: '#demo'
      });
    });
  </script>
</body>

Contributions

This project exists thanks to all the people who contribute.

Please read CONTRIBUTING before sending a pull request or issue.

License

The MIT License (MIT). Please see the License File for more information.

Credits

Written and maintained by Javi Aguilar and all other contributors.

Based on Stefan Petre's color picker (2013).

Thanks to JetBrains for supporting this project.