How to Design Color Picker using jQuery UI ? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report A ColorPicker is a jQuery UI framework tool or widget which provides a color-palette dropdown box to the user to select the color for some colorful work. It is usually connected to a text-box so that user selection of color from the color palette can be transferred to the textbox. The dropdown box can be HSV (Hue, Saturation, Value) picker or predefined RGB color palette as shown in the image. It is a very useful user interface tool as the user on the other end need not remember or know the difficult color codes. This tool can be understood as an image or text editor. Glimpse of ColorPicker using jQuery UI: If you want to attach the color-palette dropdown box on the website then you need JqueryUI Colorpicker library and include the required JavaScript(jquery.colorpicker.js) and CSS(jquery.colorpicker.css) dependencies in your PHP or HTML codes to display any jQuery UI widget. We have to use the jQuery and jQuery UI libraries and styles. You can change the files to match your style requirements. In this article, we will create the structure of the color picker in an HTML page. In the HTML web page, user input control is provided for user selection. The user input control is attached to the jQuery UI color picker widget by jQuery code. Below is the complete implementation. Creating Structure: In this section, we are creating the basic page structure and also attaching the required link which will be used. Links for the jQuery UI: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css" /> HTML Code: This example displays a simple color picker popup. As mentioned above, the downloaded dependent files (CSS and JS) for color picker are kept in folder colorpicker-master. Make sure the developer gives the correct path according to his own localhost path in the code. HTML <!DOCTYPE html> <html> <head> <title>jQueryUI | Color Picker</title> </head> <body> <h1>GeeksforGeeks</h1> <b>jQueryUI | Color Picker </b> <div class="height"></div> <br/> <body> Pick a color : <input type="text" id="my_color_picker"> </body> </body> </html> Designing Structure: In the previous section, we have created the basic code of using color picker widget. In this section, we will design the structure and attach the color picker widget to our input control where we are going to set options to override the color picker plugin's default options. Overriding the default options with your own options settings can be done in the script part of the HTML code. It is designed in a flexible way for users to choose the options needed for their applications. Links to the downloaded file: <script src="colorpicker-master/jquery.colorpicker.js"></script> <link href="colorpicker-master/jquery.colorpicker.css" rel="stylesheet" type="text/css" /> CSS Code: CSS <style> h1 { color: green; } body { text-align: center; } .height { height: 10px; } </style> JS Code: JavaScript <script> $(document).ready(function() { $(function() { $("#my_color_picker").colorpicker(); }); }); </script> Program: HTML <!DOCTYPE html> <html> <head> <title>jQueryUI | Color Picker</title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"> </script> <script src= "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"> </script> <link href= "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css" /> <!-- Include Pre-compiled files from link or download the files in your localhost folder --> <script src= "colorpicker-master/jquery.colorpicker.js"> </script> <link href= "colorpicker-master/jquery.colorpicker.css" rel="stylesheet" type="text/css" /> <style> h1 { color: green; } body { text-align: center; } .height { height: 10px; } </style> </head> <body> <h1>GeeksforGeeks</h1> <b>jQueryUI | Color Picker </b> <div class="height"></div> <br/> <body> Pick a color : <input type="text" id="my_color_picker"> <script> $(document).ready(function() { $(function() { $("#my_color_picker").colorpicker(); }); }); </script> </body> </body> </html> Output:Managing the initial color and color format: While displaying the colorpicker we can manage the initial color and color format. We can use the following jQuery code in the script section to get the result. JavaScript <script> $(function() { $( '#colorpickerId').colorpicker({ color:'#00FF00', colorFormat: ['#HEX'] }); }); </script> Managing the dialog: While displaying the color picker we can manage the dialog to be draggable if the header is visible and the dialog is not inline. We can use the following jQuery code in the script section to get the result. JavaScript <script> $(function() { $( '#colorpickerId').colorpicker({ draggable:true, }); }); </script> Managing the modal window: While displaying the color picker we can manage the color picker window as a modal window. We can use the following jQuery code in the script section to get the result. JavaScript <script> $(function() { $( '#colorpickerId').colorpicker({ modal: true, }); }); </script> Managing the none, close, and cancel buttons: While displaying the colorpicker we can manage the buttons like none, close, and cancel. We can use the following jQuery code in the script section to get the result. JavaScript <script> $(function() { $( '#colorpickerId').colorpicker({ showNoneButton: true, showCloseButton: true, showCancelButton: true, }); }); </script> Comment More infoAdvertise with us Next Article Getting Started with jQuery G geetanjali16 Follow Improve Article Tags : JQuery CSS-Misc HTML-Misc jQuery-Misc jQuery-UI +1 More Similar Reads jQuery Tutorial jQuery is a lightweight JavaScript library that simplifies the HTML DOM manipulating, event handling, and creating dynamic web experiences. The main purpose of jQuery is to simplify the usage of JavaScript on websites. jQuery achieves this by providing concise, single-line methods for complex JavaSc 8 min read Getting Started with jQuery jQuery is a fast lightweight, and feature-rich JavaScript library that simplifies many common tasks in web development. It was created by John Resign and first released in 2006. It makes it easier to manipulate HTML documents, handle events, create animations, and interact with DOM(Document Object M 4 min read jQuery Introduction jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM). jQuery simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Ajax interactions, and cross-browser Java 7 min read jQuery Syntax The jQuery syntax is essential for leveraging its full potential in your web projects. It is used to select elements in HTML and perform actions on those elements.jQuery Syntax$(selector).action()Where - $ - It the the shorthand for jQuery function.(selector) - It defines the HTML element that you w 2 min read jQuery CDN A Content Delivery Network (CDN) is a system of distributed servers that deliver web content to users based on their geographic location. Including the jQuery CDN in your project can improve the performance, enhance reliability, and simplify maintenance.What is a jQuery CDN?A jQuery CDN is a service 4 min read jQuery SelectorsJQuery SelectorsWhat is a jQuery Selector?jQuery selectors are functions that allow you to target and select HTML elements in the DOM based on element names, IDs, classes, attributes, and more, facilitating manipulation and interaction. Syntax: $(" ")Note: jQuery selector starts with the dollar sign $, and you encl 5 min read jQuery * SelectorThe jQuery * selector selects all the elements in the document, including HTML, body, and head. If the * selector is used together with another element then it selects all child elements within the element used. Syntax: $("*")Parameters: *: This parameter is used to select all elements.Example 1: Se 1 min read jQuery #id SelectorjQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript. Elaborating on the terms, it simplifies HTML document traversing and manipulation, browser event handling, DOM animations, Aja 1 min read jQuery .class SelectorThe jQuery .class selector specifies the class for an element to be selected. It should not begin with a number. It gives styling to several HTML elements. Syntax: $(".class") Parameter: class: This parameter is required to specify the class of the elements to be selected.Example 1: In this example, 1 min read jQuery EventsjQuery EventsjQuery events are actions or occurrences that happen on a web page, such as clicks, hover, or keypress. jQuery provides methods to handle and respond to these events with ease. jQuery events are used to create dynamic web pages. Syntax: $(selector).method(function)Here We will explore some basic eve 4 min read jQuery bind() MethodThe jQuery bind() method is used to attach one or more event handlers for selected elements. This method specifies a function to run when an event occurs. Syntax$(selector).bind(event, data, function);ParametersIt accepts three parameters that are described below: event: This is an event type that 2 min read jQuery blur() MethodjQuery blur() is an inbuilt method that is used to remove focus from the selected element. This method starts the blur event or it can be attached a function to run when a blur event occurs. Syntax:$(selector).blur(function)Parameters: It accepts an optional parameter "function". jQuery examples t 1 min read jQuery change() MethodThe jQuery change() method is used to detect changes in the value of form elements like <input>, <select>, or <textarea>. It triggers a specified function when a user modifies the input or selects a different option.Syntax$(selector).change(function)Parameters : It accepts an optio 2 min read jQuery EffectsjQuery animate() MethodThe animate() method is an inbuilt method in jQuery which is used to change the state of the element with CSS style. This method can also be used to change the CSS property to create the animated effect for the selected element. Syntax: (selector).animate({styles}, para1, para2, para3); Here "select 2 min read jQuery clearQueue() MethodThe jQuery clearQueue() method removes all items from the queue that have not yet been run. Note that when a function has started to run, it runs until it is completed. Syntax: $(selector).clearQueue(name); Here "selector" is the selected element. Parameter: It accepts a parameter "name" which is th 2 min read jQuery delay() MethodjQuery delay() method is an inbuilt that is used to set a timer to delay the execution of the next item in the queue. Syntax:$(selector).delay(para1, para2);Parameter: It accepts two parameters which are specified below: para1: It specifies the speed of the delay.para2: It is optional and specifies 2 min read jQuery HTML/CSSjQuery addClass() MethodThe addClass() method is an inbuilt method in jQuery that is used to add more properties to each selected element. It can also be used to change the property of the selected element. This method can be used in two different ways: 1) By adding a Class name directly: Here, the Class name can be used d 2 min read jQuery after() MethodThe after() method is an inbuilt function in jQuery which is used to insert content, specified by the parameter for each selected element in the set of matched elements. Syntax: $(selector).after(A);Parameter: It accepts a parameter "A" which is either a content or function passed to the method. Ret 1 min read jQuery append() MethodThe append() method in jQuery is used to insert some content at the end of the selected elements. Syntax: $(selector).append( content, function(index, html) ) Parameters: This method accepts two parameters as mentioned above and described below: content: It is a required parameter and is used to spe 2 min read jQuery TraversingjQuery | TraversingIn jQuery, traversing means moving through or over the HTML elements to find, filter or select a particular or entire element. Based on the traversing purposes following methods are Categorized as follows: Tree Traversing: Ancestors: parent() it gives parent element of specified selector Syntax: $(s 4 min read jQuery add() methodThe jQuery add() method is used to add elements to the existing group of elements. This method can add element to the whole document, or just inside the context element if the context parameter is defined. Syntax: $(selector).add(element, context_parameter) Here selector helps to find the matching e 1 min read jQuery addBack() MethodThe addBack() is an inbuilt method in jQuery that adds the previous set of elements to the current set. This method adds previous DOM tree elements to the current set and maintains them in the internal stack which will take care of changes to the matched set of elements. Syntax: .addBack(selector) P 2 min read Like