Basic examples
Basic color picker

Spectrum is a simple yet powerful color picker that can be used as a cross-browser alternative to native color input. It supports dropdown and flat modes with variety of options and events.

Custom button text

Apart from default button labels, you can set custom button's text or translate it using cancelText and chooseText properties. Default button labels are Cancel and Choose.

Initially empty

Spectrum picker can be initialized with an empty color value, meaning the input field value remains empty. This is very useful if the picker field needs to be validated or when field is optional.

Hide picker buttons

You can show or hide the buttons using the showButtons property. If there are no buttons, the behavior will be to fire the change event (and update the original input) when the picker is closed.

Disable color picker

Spectrum can be automatically disabled if you pass in the disabled flag. Additionally, if the input that you initialize spectrum on is disabled, this will be the default value. Note: you cannot enable spectrum if the input is disabled.

Clickout fires change

When clicking outside of the colorpicker, you can force it to fire a change event rather than having it revert the change. This is true by default. Try to pick a color and click outside to see it in action.

Picker additions
Show initial color

Spectrum can show the color that was initially set when opening. This provides an easy way to click back to what was set when opened. Pick a color and click on initial color to reset your selection.

Show alpha channel

You can allow alpha transparency selection by setting showAlpha option to true. Opacity is shown as a slider that supports values from 0 to 100 with minimum increment.

Show input and initial

If you specify both the showInput and showInitial options, the CSS keeps things in order by wrapping the buttons to the bottom row, and shrinking the input. Note: this is all customizable via CSS.

Show input field

You can add an input to allow free form typing. The color parsing is very permissive in the allowed strings. Use in combination with allowEmpty is recommended to allow empty value.

Clear selection

Setting allowEmpty option to true adds an ability to reset current selection. Spectrum inserts a square area in top right corner, which clears the selected color on click.

Full leatured

This example demonstrates a full featured color picker with combination of various options explained above: showInitial, showInput, showAlpha and allowEmpty.

Color palettes
Show color palette

Spectrum can show a palette to make it convenient for users to choose from frequently or recently used colors. When the picker is closed, the current color will be added to the palette.

Toggle palette only

Spectrum can show a button to toggle the colorpicker next to the palette. The default value for togglePaletteOnly is false. Set it to true to enable the Toggle button.

Limit selections

You can define how many elements are allowed in the selectionPallete at once. Elements will be removed from the palette in first in - first out order if this limit is reached.

Show palette only

If you'd like, spectrum can show the palettes you specify, and nothing else. To hide color picker and show only color palette, simply set showPaletteOnly and showPalette options to true.

Selection palette

Spectrum can keep track of what has been selected with the showSelectionPalette option. If the localStorageKey option is defined, the selection will be saved in the browser's localStorage object.

Hide after select

You can have the colorpicker automatically hidden after a palette color is selected. Set hideAfterPaletteSelect to true. Note: this behaviour is only available in color palette and doesn't work with color selection.

Color formats
HEX color format

You can set the format that is displayed in the text box and titles in the palette swatches. Use either preferredFormat option in JS or data-preferred-format attribute in HTML.

HSL color format

HSL stands for hue, saturation, and lightness - and represents a cylindrical-coordinate representation of colors. Color value is specified with the hsl() function, which has hsl(hue, saturation, lightness) syntax.

HTML color names

Spectrum color picker also accepts HTML color names as valid color values. You can define 140 color names, out of which 17 colors are standard. Refer to this page to see a full list.

HEX3 color format

Some six-digit hex colors can be written using a three-digit shorthand, which combines the duplicate digits from each color component into one. This results in a three digit hex number instead of six.

RGB color format

RGB color system constructs all the colors from the combination of the Red, Green and Blue colors. Each parameter (red, green, and blue) defines the intensity of the color as an integer between 0 and 255.

Mix color formats

In this example preferred color format is null, meaning it depends on input - try changing formats with the text box. Here all formats are supported and this is the default behaviour.

Picker events
Change event

Change event is called as the original input changes. Only happens when the input is closed (not by clicking 'Cancel' button) or the 'Choose' button is clicked.

Hide event

Called after the colorpicker is hidden. This happens when clicking outside of the picker while it is open. Note, when any colorpicker on the page is shown it will hide any that are already open.

Dragstart event

Dragstart event is called at the beginning of a drag event on either hue slider, alpha slider, or main color picker areas. Can be combined with other events.

Move event

Move event is called as the user moves around within the colorpicker. When the picker is closed, the last picked color value is remembered, but not considered selected.

Show event

Show event is called after the colorpicker is opened. This is ignored on a flat colorpicker. Note, when any colorpicker on the page is shown it will hide any that are already open.

Dragstop event

Dragstop event is called at the end of a drag event on either hue slider, alpha slider, or main color picker areas. Can be combined with other events.

Flat picker
Flat picker

Flat mode means that the color picker will always show up at full size, and be positioned as an inline-block element. To display color picker in flat mode, set flat option to true.

Show input field

In flat picker you can add an input to allow free form typing. The color parsing is very permissive in the allowed strings. Use in combination with allowEmpty is recommended to allow empty value

Flat color palette

Spectrum can show a palette in a flat mode to make it convenient for users to choose from frequently or recently used colors. When the picker is closed, the current color will be added to the palette.

Show initial color

Spectrum in a flat mode can show the color that was initially set. This provides an easy way to click back to what was set when opened. Pick a color and click on initial color to reset your selection.

Activity
New notifications
James has completed the task Submit documents from Onboarding list
2 hours ago
Margo has added 4 users to Customer enablement channel
3 hours ago
Subscription #466573 from 10.12.2021 has been cancelled. Refund case #4492 created
4 hours ago
Older notifications
Nick requested your feedback and approval in support request #458
3 days ago
Mike added 1 new file(s) to Product management project
new_contract.pdf
112KB
1 day ago
All hands meeting will take place coming Thursday at 13:45.
2 days ago
Christine commented on your community post from 10.12.2021
2 days ago
HR department requested you to complete internal survey by Friday
3 days ago
Loading...
Demo configuration
Color mode
Direction
Layouts
Purchase Limitless