Selector de colores

Ejemplo

Elementos emergentes con todas las funciones (panel HSV, controles deslizantes HSL, RGB y muestras de color)

En esta imagen se muestra una de las maneras en la cual podras buscar tu color...

Selector de color - Bootstrap Color Picker Sliders

Este elemento emergente muestra todas las características de forma agrupada, por lo que el usuario puede elegir el método de selección de color preferido.

HSV flat

<div id="hsvflat"></div>
<script>
    $("#hsvflat").ColorPickerSliders({
        color: "rgb(36, 170, 242)",
        flat: true,
        sliders: false,
        swatches: false,
        hsvpanel: true
    });
</script>
          

Controles deslizantes HSL y CIE Lch con muestras de color personalizables (representación plana)

<div id="hslflat"></div>
<script>
    $("#hslflat").ColorPickerSliders({
        color: "rgb(36, 170, 242)",
        flat: true,
        order: {
            hsl: 1,
            cie: 2,
            preview: 3
        }
    });
</script>
          

Diferentes tamaños y controles deslizantes de color (en elementos emergente de bootstrap)

<input type="text" class="form-control" id="small" value="#adff2f">
<input type="text" class="form-control" id="smallhsv" value="#2FB6FF">
<input type="text" class="form-control" id="default" value="#7f7f7f">
<input type="text" class="form-control" id="large" value="rgb(251, 167, 219)">
<input type="text" class="form-control" id="swatchesonly">
<input type="text" class="form-control" id="hslswatches" value="hsl(180, 50%, 50%)">
<script>
  $("input#small").ColorPickerSliders({
    size: 'sm',
    placement: 'bottom',
    swatches: false,
    order: {
      hsl: 1
    }
  });
  $("input#smallhsv").ColorPickerSliders({
    size: 'sm',
    placement: 'right',
    swatches: false,
    sliders: false,
    hsvpanel: true
  });
  $("input#default").ColorPickerSliders({
    placement: 'bottom',
    swatches: false,
    order: {
      rgb: 1
    }
  });
  $("input#large").ColorPickerSliders({
    size: 'lg',
    placement: 'bottom',
    swatches: false,
    order: {
      cie: 1
    }
  });
  $("input#swatchesonly").ColorPickerSliders({
    placement: 'bottom',
    color: 'red',
    swatches: ['red', 'green', 'blue'],
    customswatches: false,
    order: {}
  });
  $("input#hslswatches").ColorPickerSliders({
    placement: 'bottom',
    order: {
      hsl: 1,
      opacity: 2
    }
  });
</script>
          

Utilizando el evento onchange()

<button class="btn btn-default" id="bgcolor">Cambiar el color del body bg</button>
<script>
        $("#bgcolor").ColorPickerSliders({
            color: 'white',
            previewontriggerelement: false,
            title: 'Body background color',
            order: {
                rgb: 1,
                preview: 2
            },
            onchange: function(container, color) {
                var body = $('body');

                body.css("background-color", color.tiny.toRgbString());

                if (color.cielch.l < 60) {
                    body.css("color", "white");
                }
                else {
                    body.css("color", "black");
                }
            }
        });
</script>
          

Representación plana completa

Este ejemplo muestra los controles deslizantes CIE Lch que están diseñados para aproximarse a la visión humana. Significa que el amarillo y el azul con la misma ligereza CIE son idénticos a los humanos (que no es el caso con HSL donde el azul parece ser mucho más oscuro que el amarillo con la misma ligereza HSL).

CIE Lch es un modelo de color especial en el que no todos los colores son reproducibles en el mundo físico, por lo que este plugin simplemente reduce el cromatismo de estos colores para que sea convertible a RGB. Puedes leer más sobre esto en 5Wikipedia.

<div id="flat"></div>
<script>
    $("#flat").ColorPickerSliders({
        flat: true,
        invalidcolorsopacity: 0
    });
</script>
          
invalidcolorsopacity hides the colors from the CIE sliders whose can not be converted to RGB without lowering their chroma values. It is good for creating color schemas.

Valores Slier y control preciso

Todos los valores del deslizador estarán visibles cuando rendervalues se establezca en true .
             Los valores se pueden controlar con precisión mediante botones si slidersplusminus se establece en true.

<script>
  $("#sliders-plusminus").ColorPickerSliders({
    placement: 'bottom',
    size: 'lg',
    previewformat: 'hsl-rgb',
    swatches: false,
    sliders: true,
    title: 'Values and plus/minus buttons',
    order: {
      preview: 1,
      hsl: 2,
      opacity: 3,
      rgb: 4,
      cie: 5
      },
    rendervalues: true,
    slidersplusminus: true
  });
</script>
          

Configuraciones

Option Description
color This is the initial color if there is no valid (any CSS formatted) color value on the connected input element. Can be in any format that Tiny Color supports.
size 'sm': Small sized popover.
'default': Default popover size.
'lg': Large popover.
placement Popover placement direction. Can be 'auto' | 'top' | 'left' | 'bottom' | 'right'.
When 'auto' is specified, it will dynamically reorient the popover. For example, if placement is 'auto left', the tooltip will display to the left when possible, otherwise it will display right.
preventtouchkeyboardonshow true: Makes the input readonly to prevent touch keyboard to show up on focus, needs a second click to become editable.
title '': Popover title.
hsvpanel false: Enable/disable HSV color selector panel.
sliders true: Enable/disable the sliders.
grouping true: Enable/disable grouping of the HSV panel, Sliders and Swatches section.
trigger 'focus': The popover will be visible on focus or on click.
'manual': No auto trigger of popover on focus/click. Must trigger colorpickersliders.show and colorpickersliders.hide events to show/hide the popover.
flat false: The color picker is rendered in a popup, which is shown on focus of the connected element.
true: The color picker is rendered right after the connected element, and is always visible.
previewformat This is the color format on the preview slider (if visible). Can be rgb, hsl, hex or hsl-rgb. Note that hex format can not represent the opacity value. Warning: hsl-rgb can be too wide for preview field.
swatches array: Array of CSS colors (can be CSS color names as well).
false: The swatches are disabled.
customswatches string: Name of the custom swatches group. Color pickers with the same customswatches name share the same swatch colors, so if you add a new color to one of the color pickers, then all the color pickers swatches will be updated on the page which has the same customswatches name.
false: The custom swatches are disabled, so only the predefined swatches can be used.
connectedinput selector or jQuery object: The connected input elements value will be automatically updated in sync with the color picker. The color format which the color is represented i the input can be set via the data-color-format property. It can be any of hex, hsl or rgb. If it is hex, then the opacity will be discarded.
updateinterval Update interval of the sliders while dragging (ms). The default is 30.
previewontriggerelement true: Preview of the color on the connected element's background.
false: No preview on the connected element.
previewcontrasttreshold 30: If previewontriggerelement is enabled, then if the lightness is below of this value, the element's text color will be white. Otherwise the text is black.
erroneousciecolormarkers true: Unconvertable CIE colors are marked with an exclamation mark on the CIE sliders level marker.
false: No exclamation mark on the markers.
invalidcolorsopacity 1: Opacity of the invalid (unconvertable) area of the CIE sliders.
finercierangeedges true: Sharper, more accurate edges of the valid CIE ranges on the sliders.
false: Smoother edges of the valid CIE ranges on the sliders.
order An object which defines which sliders appear and in which order.
Possible properties: opacity, hsl, rgb, cie, preview.
labels An object which defines the labels of the sliders.
Possible properties: hslhue, hslsaturation, hsllightness, rgbred, rgbgreen, rgbblue, cielightness, ciechroma, ciehue, opacity, preview.
onchange function(container, color): This function is triggered when the color is changed with the sliders or via a connected input. The color parameter holds the actual color object in the following formats: rgb object, hsl object, cie lch object, Tiny Color object.
titleswatchesadd string: Title of the add color to swatches button.
titleswatchesreset string: Title of the reset swatches button.
rendervalues true: Display currently selected value in each slider.
false: Just show default normal sliders.
slidersplusminus true: Display -1 and +1 buttons left and right of each slider. Clicking on them decreases or increases slider value by 1.
false: Just show default normal sliders.

Events

Example usage: $("#colorpicker").trigger("colorpickersliders.updateColor", "red"));

The following events can be triggered on the element which the color picker is initialized on.

Event Description
colorpickersliders.updateColor function(newcolor): Sets a new color for the color picker.
colorpickersliders.show function(): Shows the popover.
colorpickersliders.hide function(): Hiddens the popover.