Vivid API

Color Picker

Allows users to select any color using a dedicated Color Picker interface.

Usage

import '@vonage/vivid-api/color-picker';

or, if you need to use a unique prefix:

import { registerColorPicker' } from '@vonage/vivid-api';
registerColorPicker('your-prefix');

Open

Use the open attribute to indicate whether the Simple Color Picker’s popup should be open.

  • Type: boolean
  • Default: false

Saved Colors

Saved Colors Key

Saved colors are stored in the browser’s localStorage by default, using a key generated from the component’s tag name.

To ensure persistence and uniqueness, it’s good practice to specify a custom key using the saved-colors-key attribute.

Disable Saved Colors

You can use the disabled-saved-colors attribute to disable saving colors by the users.

  • Type: boolean
  • Default: false

Slots

Contextual Help

The contextual-help slot allows you to add the Contextual Help component next to the label.

Helper Text

The helper-text slot allows you to use rich content as the Color Picker’s helper text.

The popup-text slot allows you to override the default “Color Picker” title displayed in the Color Picker’s popup.

Swatches Text

The swatches-text slot allows you to override the default “Saved Colors:” text displayed above the color swatches.

API Reference

Properties

PropertyTypeDefaultDescription
disableSavedColorsbooleanDisables the saving colors functionality
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
errorTextstringProvides a custom error message. Any current error state will be overridden.
helperTextstringProvides additional information to help the user enter the correct information. To add HTML to the helper text, use the helper-text slot instead.
initialValuestringThe default value of the element. This value sets the `value` property only when the `value` property has not been explicitly set.
labelstringThe label for the form element.
maxSwatchesnumberLimits number of swatches that can be saved.
namestringThe name of the element. This element's value will be surfaced during form submission under the provided name.
openbooleanIndicates whether the popup is open
placeholderstringText that appears in the input element when it has no value set
requiredbooleanRequire the field to be completed prior to form submission.
savedColorsKeystringSets the localStorage key used to store saved colors explicitly
successTextstringProvides a custom success message. Any current error state will be overridden.
swatches{label?: string; value: string}[]List of color swatches, has to be an array of objects
value
(modelValue)
stringThe current value of the element.
PropertyTypeDefaultDescription
disable-saved-colorsbooleanDisables the saving colors functionality
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
error-textstringProvides a custom error message. Any current error state will be overridden.
helper-textstringProvides additional information to help the user enter the correct information. To add HTML to the helper text, use the helper-text slot instead.
valuestringThe default value of the element. This value sets the `value` property only when the `value` property has not been explicitly set.
labelstringThe label for the form element.
max-swatchesnumberLimits number of swatches that can be saved.
namestringThe name of the element. This element's value will be surfaced during form submission under the provided name.
openbooleanIndicates whether the popup is open
placeholderstringText that appears in the input element when it has no value set
requiredbooleanRequire the field to be completed prior to form submission.
saved-colors-keystringSets the localStorage key used to store saved colors explicitly
success-textstringProvides a custom success message. Any current error state will be overridden.
swatches
(property only)
{label?: string; value: string}[]List of color swatches, has to be an array of objects
current-valuestringThe current value of the element.

Slots

NameDescription
contextual-helpSlot for the contextual-help component, displayed next to the label.
helper-textDescribes how to use the text-field. Alternative to the `helper-text` attribute.
popup-textOverrides the default "Color Picker" title of the Popup window.
swatches-textOverrides the default "Saved colors:" text above color swatches.
NameDescription
contextual-helpSlot for the contextual-help component, displayed next to the label.
helper-textDescribes how to use the text-field. Alternative to the `helper-text` attribute.
popup-textOverrides the default "Color Picker" title of the Popup window.
swatches-textOverrides the default "Saved colors:" text above color swatches.

Events

NameTypeDescription
changeCustomEvent<undefined>Fires when the value changes
inputEventFires when the value of the element changes.
NameTypeDescription
changeCustomEvent<undefined>Fires when the value changes
inputEventFires when the value of the element changes.

Methods

NameParamsReturnsDescription
checkValiditybooleanReturn the current validity of the element.
reportValiditybooleanReturn the current validity of the element. If false, fires an invalid event at the element.