Vivid API

Simple Color Picker

The basic version of the Color Picker allows users to select a color from a predefined palette.

Usage

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

or, if you need to use a unique prefix:

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

Open

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

  • Type: boolean
  • Default: false

Anchor

It is recommended use the anchor slot to set the anchor.

The anchor attribute should be set to the id value of the anchor element or pass the anchor element itself.

Pay attention to the source order the components to ensure they can be operated logically using only a keyboard.

Slots

Anchor Slot

Simple Color Picker needs to be anchored to an element. Place the anchor element inside the anchor slot of the Simple Color Picker. It is recommended to use the Button component as the anchor element.

API Reference

Properties

PropertyTypeDefaultDescription
anchorstring | HTMLElementID or direct reference to the component's anchor element.
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
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.
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
placement'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start'Preferred placement of the Color Picker's popup in relation to the anchor element
requiredbooleanRequire the field to be completed prior to form submission.
swatches{label?: string; value: string}[]List of color swatches, has to be an array of objects
swatchesPerRownumberNumber of swatches per row for grid layout
value
(modelValue)
stringThe current value of the element.
PropertyTypeDefaultDescription
anchorstring | HTMLElementID or direct reference to the component's anchor element.
disabledbooleanSets the element's disabled state. A disabled element will not be included during form submission.
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.
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
placement'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start'Preferred placement of the Color Picker's popup in relation to the anchor element
requiredbooleanRequire the field to be completed prior to form submission.
swatches
(property only)
{label?: string; value: string}[]List of color swatches, has to be an array of objects
swatches-per-rownumberNumber of swatches per row for grid layout
current-valuestringThe current value of the element.

Slots

NameDescription
anchorSlot for attaching the toggle button
NameDescription
anchorSlot for attaching the toggle button

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.