"color swatch picker"
Bootstrap 3.2.0 Snippet by escapedlion

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-success btn-add">+</button>
</span>
<input type="text" name="color" class="form-control">
<div class="input-group-btn group-color">
<button type="button" class="btn btn-default btn-box dropdown-toggle" data-toggle="dropdown">
<span class="fa fa-square" id="preview"></span>
</button>
<ul class="dropdown-menu">
<li>
<div class="panel panel-default">
<div class="panel-heading">
<span class="panel-label">Color Swatch</span>
</div>
<div class="panel-body">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<style type="text/css">
.container {margin-top: 25px;}
.row {margin-top: 25px;}
.swatch
{
width:46px;
height:46px;
border-radius:5px;
border: 1px solid #666;
margin: 0px;
}
div.group-color > ul.dropdown-menu
{
box-shadow: 0;
padding: 0;
left: -280px;
width: 320px;
}
.panel
{
margin-bottom: 0;
padding: 0;
}
ul.list-inline li
{
padding:0;
margin: 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$('.swatch-clickable').each(function ()
{
$(this).attr('title', $(this).attr('id'));
});
$('.swatch-clickable').tooltip();
$(".swatch-clickable").click(function()
{
$("#preview").css('color', $(this).css('background-color'));
$("#color-field").val($(this).attr("id"))
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments:

will be good if selected color value is loaded to input value field so that can be send to server side ...

Zahid Ullah () - 8 years ago - Reply 0