UI Widgets ColorBox

A widget used to specify a color value.

Included in: dx.webappjs.js, dx.all.js
ColorBox interactive configuration
Copy code
$("#colorbox").dxColorBox({
});

The dxColorBox widget allows a user to either specify a color value manually or pick it out from the drop-down editor.

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxColorBox jQuery plug-in.

    HTML
    <div id="colorBox"></div>
    JavaScript
    $("#colorBox").dxColorBox({
        value: 'rgba(255, 144, 0, 0.3)',
        editAlphaChannel: true
    });
  • Knockout
    Add a div element and apply the dxColorBox binding to this element.

    HTML
    <div data-bind="dxColorBox: {
        value: 'rgba(255, 144, 0, 0.3)',
        editAlphaChannel: true
    }"></div>
  • Angular
    Add a div element and apply the dx-color-box directive to this element.

    HTML
    <div dx-color-box="{
        value: 'rgba(255, 144, 0, 0.3)',
        editAlphaChannel: true
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries to your application. If you use the Knockout or Angular approach, the Knockout or Angular library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

You can find detailed information on the principles of working with the widget in the dxColorBox section of the Editor Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div style="height:500px; max-width:750px; margin: 0 auto" ng-controller="demoController">
    <div ng-model="colorValue" dx-color-box="{ }"></div>
    <p class="text" ng-style="{ color: colorValue }">Colored Text</p>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.colorValue = "#FF0000";
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body{
    text-align: center;
}
.text{
    margin-top: 50px;
    font-size: 100px;
}
<div style="height:500px; max-width:750px; margin: 0 auto">
    <div data-bind="dxColorBox: { value: colorValue }"></div>
    <p class="text" data-bind="style: { color: colorValue }">Colored Text</p>
</div>
var myViewModel = {
    colorValue: ko.observable("#FF0000")
}
ko.applyBindings(myViewModel);
body{
    text-align: center;
}
.text{
    margin-top: 50px;
    font-size: 100px;
}
<div style="height:500px; max-width:750px; margin: 0 auto">
    <div id="myColorBox"></div>
    <p class="text" id="coloredText">Colored Text</p>
</div>
$("#myColorBox").dxColorBox({
    value: "#FF0000",
    onValueChanged: function (e) {
        $("#coloredText").css("color", e.value);
    }
});
$("#coloredText").css("color", $("#myColorBox").dxColorBox("instance").option("value"));
body{
    text-align: center;
}
.text{
    margin-top: 50px;
    font-size: 100px;
}

Configuration

An object defining configuration options for the dxColorBox widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.