Skip to main content

Color Picker

Rocket 2.0

The Color Picker component lets the user choose a color from preset swatches, a saturation and hue picker, or by typing a hex code. Use it for settings such as a brand or label color.

Properties​

Property
Description
Expected Value
LabelText shown above the field.Text. Default: Brand color
Help textHelp text shown under the field.Text
Default colorThe color the field starts with, as a hex code such as #6366f1. Changing it resets the field to this color.Text. Default: #6366f1
PlaceholderText shown in the field when no color is chosen.Text. Default: Pick a color
Preset swatchesPreset colors shown in the picker, as a list of hex codes.Array
Show swatchesShows the preset swatches in the picker.On or off. Default: On
Show saturation and hue pickerShows the saturation and brightness area and the hue slider in the picker.On or off. Default: On
Allow transparency (alpha)Adds an opacity slider so the user can choose a semi-transparent color. The hex code then includes the alpha value.On or off. Default: Off
TriggerHow the closed field looks: Swatch and hex shows the color and its code, Swatch only shows just the color.Swatch and hex, Swatch only. Default: Swatch and hex
Show clear buttonShows a button that clears the chosen color.On or off. Default: Off

Additional Actions​

Each of these can be switched on or off, or set with a logical expression by clicking fx.

Property
Description
Expected Value
VisibilityShows or hides the component. Hidden components keep their space unless Collapse when hidden is on.On or off. Default: On
Collapse when hiddenRemoves the hidden component's space, so the components below it move up.On or off. Default: Off
Loading stateShows the component's loading look and blocks interaction, for example while a query runs.On or off. Default: Off
DisableStops the user from interacting with the component.On or off. Default: Off
Dynamic heightLets the component grow with its content in the running app instead of keeping a fixed height.On or off. Default: Off

Devices​

Property
Description
Expected Value
Show on desktopShows the component in the desktop layout.On or off. Default: On
Show on mobileShows the component in the mobile layout.On or off. Default: Off

Events​

Add a handler from the Events section of the properties panel. See Event Triggers for the steps.

Event
Description
On changeTriggers when the user picks a different color or clears it.
On focusTriggers when the user opens the color picker.
On blurTriggers when the color picker closes.

Component Specific Actions (CSA)​

Run these from an event handler with Control Component, or from a RunJS query. See Component Specific Actions.

Action
Description
How To Access
Set colorSets the chosen color to Color. An empty value clears it.components.colorpicker1.setColor("")
Set focusMoves keyboard focus to the field.components.colorpicker1.setFocus()
Set blurRemoves keyboard focus from the field.components.colorpicker1.setBlur()
Set visibilityShows the component when true, hides it when false.components.colorpicker1.setVisibility(false)
Set disableDisables the component when true, enables it when false.components.colorpicker1.setDisable(false)
Set loadingTurns the loading state on with true, off with false.components.colorpicker1.setLoading(false)

Exposed Variables​

Variable
Description
How To Access
labelText shown above the field.{{components.colorpicker1.label}}
descriptionHelp text shown under the field.{{components.colorpicker1.description}}
defaultValueThe color the field starts with, as a hex code such as #6366f1. Changing it resets the field to this color.{{components.colorpicker1.defaultValue}}
placeholderText shown in the field when no color is chosen.{{components.colorpicker1.placeholder}}
swatchesPreset colors shown in the picker, as a list of hex codes.{{components.colorpicker1.swatches}}
showSwatchesShows the preset swatches in the picker.{{components.colorpicker1.showSwatches}}
showPickerShows the saturation and brightness area and the hue slider in the picker.{{components.colorpicker1.showPicker}}
allowAlphaAdds an opacity slider so the user can choose a semi-transparent color. The hex code then includes the alpha value.{{components.colorpicker1.allowAlpha}}
triggerStyleHow the closed field looks: Swatch and hex shows the color and its code, Swatch only shows just the color.{{components.colorpicker1.triggerStyle}}
showClearBtnShows a button that clears the chosen color.{{components.colorpicker1.showClearBtn}}
valueThe chosen color as a hex code, such as #6366f1, or empty when no color is chosen.{{components.colorpicker1.value}}
selectedColorRGBThe chosen color in rgb() form.{{components.colorpicker1.selectedColorRGB}}
selectedColorRGBAThe chosen color in rgba() form, including opacity.{{components.colorpicker1.selectedColorRGBA}}
isVisibleWhether the component is visible.{{components.colorpicker1.isVisible}}
isLoadingWhether the component is in its loading state.{{components.colorpicker1.isLoading}}
isDisabledWhether the component is disabled.{{components.colorpicker1.isDisabled}}

Styles​

Style
Default
Label colorTheme: Primary text
Help text colorTheme: Placeholder text
Field backgroundTheme: Surface 1
Field text colorTheme: Primary text
Placeholder colorTheme: Placeholder text
Field border colorTheme: Default border
Accent (focus ring)Theme: Brand primary
Field radius—
Popover backgroundTheme: Surface 1
Box shadow0px 0px 0px 0px #00000040

A default that starts with Theme: follows the app's theme until the style is set to another value. See App Themes.