Skip to content

JavaScript Color Picker

The jSuites.color is a versatile and lightweight JavaScript color picker for seamless integration into web projects. Whether you're working with standalone applications or incorporating them into React, Angular, or Vue frameworks, this color picker is engineered for adaptability. It offers a straightforward and intuitive color selection interface, enhancing the user experience. Key features include:

  • Framework Compatibility: Works effortlessly with popular frameworks like React, Angular, and Vue;
  • Mobile-Optimized: Delivers a responsive and mobile-friendly user interface;
  • Customization: Allows tailored color choices and palette configurations;
  • Event Integration: Supports various events to help with integrations;
  • Versatility: Can be utilized as a JavaScript plugin or web component;

jSuites Color Picker - Lightweight & Framework Compatible

Section titled “jSuites Color Picker - Lightweight & Framework Compatible”

This page documents the jSuites Color Picker, a lightweight vanilla JavaScript color picker plugin compatible with React, Angular, and Vue.

Best for:

  • Simple color selection needs
  • Framework-agnostic projects
  • Lightweight implementations
  • No build tools required

LemonadeJS Color Picker - Reactive Component

Section titled “LemonadeJS Color Picker - Reactive Component”

For applications requiring reactive data binding and enhanced framework integration, LemonadeJS Color Picker offers:

  • Reactive Design: Two-way data binding with automatic updates
  • Lightweight: 2.59KB gzipped
  • Framework Integration: Seamless Vue, React, Angular support
  • Dual Modes: Inline and modal display options
  • Personal Palette: Customizable user color collections

Explore LemonadeJS Color Picker →


FeaturejSuitesLemonadeJS
SizeLightweight2.59KB gzipped
Reactive-✓ Two-way binding
Framework SupportCompatible✓ Integrated
Custom Palettes✓✓ Personal + Gradient
Display ModesStandardInline + Modal
Best ForSimple pickersReactive apps

npm install jsuites
MethodDescription
color.open();Open the color picker
color.close(boolean);Close the color picker
@param int ignoreEvents - Do no execute onclose event
color.getValue();Get the current value of the color picker
color.setValue(string);Set a new value to the color picker
@param hex newColor - Set a new value
MethodDescription
onchangeMethod executed when a value is changed.
(HTMLElement element, String color) => void
oncloseMethod executed when the color picker is closed.
(HTMLElement element) => void
onopenMethod executed when the color picker is opened.
(HTMLElement element) => void
PropertyDescription
fullscreen: booleanWhether to open in fullscreen mode. Default: false.
value: stringInitial value of the component
palette: Array of colorsCustom colors
placeholder: stringThe default instruction text on the element
closeOnChange: booleanAuto-close on color selection
doneLabel: stringLabel for the done button
resetLabel: stringLabel for the reset button

Create a color picker as a web component:

<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<script src="https://jsuites.net/v6/jsuites.webcomponents.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />
<jsuites-color value="#009688"></jsuites-color>
<script>
document.querySelector('jsuites-color').addEventListener('onchange', function(e) {
    // Set the font color
    e.target.children[0].style.color = this.value;
    // Show on console
    console.log('New value:' + this.value);
});
</script>
</html>

A basic javascript color picker event bound to an HTML input element.

<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />
<input id="basic-color-picker"/>
<script>
let color = jSuites.color(document.getElementById('basic-color-picker'), {
    onchange: function(e, color) {
        // Set the font color
        e.style.color = color;
        // Show on console
        console.log('New value:' + color);
    }
});
</script>
</html>

Create a color input with custom colors:

<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />
<input id="custom-color-picker"/>
<script>
jSuites.color(document.getElementById('custom-color-picker'), {
    palette: [
        ['#001969', '#233178', '#394a87', '#4d6396', '#607ea4', '#7599b3' ],
        ['#00429d', '#2b57a7', '#426cb0', '#5681b9', '#6997c2', '#7daeca' ],
        ['#3659b8', '#486cbf', '#597fc5', '#6893cb', '#78a6d1', '#89bad6' ],
        ['#003790', '#315278', '#48687a', '#5e7d81', '#76938c', '#8fa89a' ],
    ]
});
</script>
</html>