Vivid API

Color Picker

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

Labelling

Label Text

The label attribute provides a short description of the purpose of the Color Picker.

If a visible label can’t be used, provide one using the

aria-label

attribute. This ensures screen readers announce the purpose of the element, making it accessible to all users.

Helper Text

The helper-text attribute provides additional information about the purpose of the Color Picker.
To add HTML to the helper text, use the helper-text slot.

Placeholder Text

The placeholder attribute provides some text to be displayed when no color is selected.

Contextual Help

You can add the Contextual Help component using the contextual-help slot. It will be displayed next to the label, providing users additional information.

Validation Feedback

Error Text

The error-text attribute provides a custom error message. Any current error state will be overridden by error-text.

Success Text

The success-text attribute provides a custom success message. Any current error state will be overridden by success-text.

Value

The value attribute can be used to set the default value for the Color Picker element.

Swatches

The swatches attribute can be used to set the default color palette that will be displayed in the Color Picker’s Popup.

It accepts an array of objects with value and label properties: [{"label": "Red", "value": "#ff0000"}, {"value": "#00ff00"}]. The optional label property provides descriptive text for screen readers, improving accessibility.

Max Swatches

The maximum number of displayed color swatches (either saved by the user or passed using swatches attribute) can be set using the max-swatches attribute.

Swatches Text

The default “Saved Colors:” text displayed above the color swatches can be overridden with swatches-text slot.

Disabled

The disabled attribute disables the Color Picker element.