• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

Color Picker

Gone are the days to manually enter in hex codes to select colors.

ColorPicker Tag Documentation

ColorPicker is an input component with a color palette.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
accesskey String false Access key to transfer focus to the input element.
alpha boolean false true When enabled, includes alpha channel (transparency).
alt String false Alternate textual description of the input field.
ariaDescribedBy String false Identifies the element(s) that describe the object, enhancing accessibility.
autocomplete String false Controls browser autocomplete behavior. Possible values are 'on', 'off', and 'new-password'.
clearButton boolean false false When enabled, shows clear button.
closeButton boolean false false When enabled, shows close button.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
converterMessage String false Custom message to display when conversion fails.
dir String false ltr Direction indication for text that does not inherit directionality.
disabled boolean false false Specifies that an element should be disabled.
focusInput boolean false true When enabled, focuses the input field.
forceAlpha boolean false false When enabled, forces alpha channel to be always visible.
format String false hex Color format. Options: 'hex', 'rgb', 'hsl', 'hsv'.
formatToggle boolean false false When enabled, allows toggling between color formats.
immediate boolean false false When set true, process validations logic is executed at apply request values phase for this component.
inputmode String false Specifies the type of data expected in the input, aiding virtual keyboards.
label String false A localized user presentable name.
lang String false Specifies the language of the element's content.
localValueSet boolean false false Indicates whether the local value of the component has been set.
locale Object false Locale for the color picker.
maxlength int false Integer.MIN_VALUE Defines the maximum number of characters allowed in the input.
mode String false popup Display mode. Options: 'popup', 'inline'.
onblur String false Fires when an element loses focus.
onchange String false Fires when the value of an element has been changed.
onclick String false Fires when a mouse click on the element.
oncontextmenu String false Script to execute when the context menu is triggered.
oncopy String false Script to execute when content is copied from the element.
oncut String false Script to execute when content is cut from the element.
ondblclick String false Fires when a mouse double-click on the element.
ondrag String false Script to execute when an element is dragged.
ondragend String false Script to execute at the end of a drag operation.
ondragenter String false Script to execute when a dragged element enters a valid drop target.
ondragleave String false Script to execute when a dragged element leaves a valid drop target.
ondragover String false Script to execute when a dragged element is over a valid drop target.
ondragstart String false Script to execute at the start of a drag operation.
ondrop String false Script to execute when a dragged element is dropped.
onfocus String false Fires when an element gets focus.
oninput String false Script to execute when the element receives user input.
oninvalid String false Script to execute when the element's value is invalid.
onkeydown String false Fires when a user is pressing a key.
onkeypress String false Fires when a user presses a key.
onkeyup String false Fires when a user releases a key.
onmousedown String false Fires when a mouse button is pressed down on an element.
onmousemove String false Fires when the mouse pointer is moving while it is over an element.
onmouseout String false Fires when the mouse pointer moves out of an element.
onmouseover String false Fires when the mouse pointer moves onto an element.
onmouseup String false Fires when a mouse button is released over an element.
onpaste String false Script to execute when content is pasted into the element.
onreset String false Script to execute when the form is reset.
onscroll String false Script to execute when the element is scrolled.
onsearch String false Script to execute when a search is performed.
onselect String false Script to execute when text is selected.
onwheel String false Script to execute when the mouse wheel is used.
placeholder String false Specifies a short hint describing the expected value of the input.
readonly boolean false false Specifies that an input field is read-only.
required boolean false false Marks component as required.
requiredMessage String false Custom message to display when the required validation fails.
role String false Defines the role of the element for accessibility purposes.
selectInput boolean false false When enabled, selects the input text on focus.
size int false Integer.MIN_VALUE Number of characters used to determine the width of the input element.
style String false Specifies an inline CSS style for an element.
styleClass String false Specifies one or more CSS class names for an element.
submittedValue Object false
swatches String false Comma-separated list of color swatches to display.
swatchesOnly boolean false false When enabled, shows only color swatches.
tabindex String false Specifies the tab order of an element.
theme String false default Color picker theme.
themeMode String false auto Theme mode. Options: 'auto', 'light', 'dark'.
title String false Specifies extra information about an element (displayed as a tooltip).
type String false text Input field type.
valid boolean false true Indicates whether the input's value is valid.
validator Validator false A method expression referring to a method validating the input.
validatorMessage String false Custom message to display when validation fails.
value Object false Value of the component.
valueChangeListener ValueChangeListener false A method binding expression referring to a method for handling a valuchangeevent.
Loading...
Tag DocumentationNew DocumentationNew Documentation JSDoc Popup Inline
Popup

Usage


<style>
.square .clr-field button, .circle .clr-field button {
    width: 22px;
    height: 22px;
    left: 5px;
    right: auto;
    border-radius: 5px;
}

.square .clr-field input, .circle .clr-field input {
    padding-left: 36px;
}

.circle .clr-field button {
    border-radius: 50%;
}
</style>

<h:form>
    <div class="card">
        <p:growl>
            <p:autoUpdate />
        </p:growl>

        <h5>Popup</h5>
        <div class="ui-fluid grid formgrid">
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Ajax" />
                <p:colorPicker id="ajax" value="#{colorView.ajax}"
                    clearButton="true" closeButton="true" alpha="false">
                    <p:ajax event="open" listener="#{colorView.onPopupOpened}" />
                    <p:ajax event="close" listener="#{colorView.onPopupClosed}" update="@this" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="pill" value="Pill (horizontal)" />
                <p:colorPicker id="pill" value="#{colorView.pill}" theme="pill"
                    formatToggle="true" clearButton="true" closeButton="true"
                    alpha="false">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Polaroid (skinny)" />
                <p:colorPicker id="polaroid" value="#{colorView.polaroid}"
                    theme="polaroid" formatToggle="true" clearButton="true"
                    closeButton="true" alpha="false">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Large" />
                <p:colorPicker id="large" value="#{colorView.large}" theme="large"
                    formatToggle="true" clearButton="true" closeButton="true"
                    forceAlpha="true">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Swatches Only" />
                <p:colorPicker id="swatches" value="#{colorView.swatches}"
                    swatchesOnly="true" theme="polaroid" clearButton="false"
                    closeButton="false"
                    swatches="#264653, #2a9d8f, #e9c46a, #f4a261, #e76f51, #d62828, #023e8a, #0077b6, #0096c7, #00b4d8, #48cae4">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2 thumbnail">
                <p:outputLabel for="@next" value="Thumbnail" />
                <p:colorPicker id="thumbnail" value="#{colorView.thumbnail}"
                    swatchesOnly="true" theme="polaroid" clearButton="true"
                    closeButton="true"
                    swatches="#264653, #2a9d8f, #e9c46a, #f4a261, #e76f51, #d62828, #023e8a, #0077b6, #0096c7, #00b4d8, #48cae4">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Dark Mode" />
                <p:colorPicker id="dark" value="#{colorView.dark}" theme="pill"
                    themeMode="dark" clearButton="true" closeButton="true"
                    formatToggle="true"
                    swatches="#067bc2, #84bcda, #80e377,  #ecc30b, #f37748, #d56062">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Light Mode" />
                <p:colorPicker id="light" value="#{colorView.light}" theme="pill"
                    themeMode="light" clearButton="true" closeButton="true"
                    formatToggle="true"
                    swatches="#067bc2, #84bcda, #80e377,  #ecc30b, #f37748, #d56062">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Alpha" />
                <p:colorPicker id="alpha" value="#{colorView.alpha}"
                    clearButton="true" closeButton="true" alpha="true"
                    forceAlpha="true">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="rgb" value="RGB" />
                <p:colorPicker id="rgb" value="#{colorView.rgb}" theme="large"
                    clearButton="true" closeButton="true" format="rgb">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="HSL" />
                <p:colorPicker id="hsl" value="#{colorView.hsl}" theme="large"
                    clearButton="true" closeButton="true" format="hsl">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2 circle">
                <p:outputLabel for="@next" value="Circle" />
                <p:colorPicker id="circle" value="#{colorView.circle}"
                    format="auto">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2 square">
                <p:outputLabel for="@next" value="Square" />
                <p:colorPicker id="square" value="#{colorView.square}"
                    format="auto">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="RTL" />
                <p:colorPicker id="rtl" value="#{colorView.rtl}" theme="large"
                    dir="rtl" formatToggle="true" clearButton="true"
                    closeButton="true" forceAlpha="true">
                    <p:ajax event="change" listener="#{colorView.onColorChange}" />
                </p:colorPicker>
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Disabled" />
                <p:colorPicker disabled="true" value="#000000" />
            </div>
            <div class="field col-12 md:col-2">
                <p:outputLabel for="@next" value="Error" />
                <p:colorPicker value="#FFFFFF" class="ui-state-error" />
            </div>
            <div class="field col-12 md:col-2 mt-5">
                <span class="ui-float-label"> 
                    <p:colorPicker clearButton="true" closeButton="true" alpha="false" /> 
                    <p:outputLabel for="@previous" value="Float Label" />
                </span>
            </div>
        </div>
        
         <p:commandButton value="Open Dialog" type="button" icon="pi pi-external-link" onclick="PF('dlg').show()"/>
    </div>

    <p:dialog header="Pick Color" widgetVar="dlg" minHeight="50" width="350" showEffect="fade" modal="true">
        <div style="height: 300px">
        <p:outputLabel for="@next" value="Pick Color:" />
        <p:colorPicker id="dialogPicker" clearButton="true" closeButton="true" alpha="false" />
        </div>
        <f:facet name="footer">
            <p:commandButton type="button" value="Close" style="width: 5rem" onclick="PF('dlg').hide()"/>
        </f:facet>
    </p:dialog>
</h:form>