
# Class: AuWidgetColorPicker

A widget that is used to select colors in the editor.

```
{
  "widgets": [
    {
      "title": "Background Color",
      "name": "colors",
      "type": "color-picker",
      "params": {
        "text": "Choose a background",
        "type": "color",
        "colors": [
          {
            "value": "Beige",
            "displayColor": "#dac0a3"
          },
          {
            "value": "Kelly Green",
            "displayColor": "#017c60"
          },
          {
            "value": "Yellow",
            "displayColor": "#fed505"
          },
          {
            "value": "Teal",
            "displayColor": "#009ead"
          }
        ]
      }
    }
  ]
}
```

## Hierarchy

  ↳ [AuBaseSelectorWidget](aubaseselectorwidget.md)

  ↳ **AuWidgetColorPicker**

## Implements

* [IWidget](../interfaces/iwidget.md)
* [IRestorableWidget](../interfaces/irestorablewidget.md)

## Index

### Properties

* [color](auwidgetcolorpicker.md#color)
* [params](auwidgetcolorpicker.md#params)

### Accessors

* [_](auwidgetcolorpicker.md#_)

### Methods

* [checkInitDependenciesWidgets](auwidgetcolorpicker.md#checkinitdependencieswidgets)
* [clearSelection](auwidgetcolorpicker.md#clearselection)
* [closePicker](auwidgetcolorpicker.md#closepicker)
* [exportWidgetData](auwidgetcolorpicker.md#exportwidgetdata)
* [resetPreloaderState](auwidgetcolorpicker.md#resetpreloaderstate)
* [restoreWidgetFromData](auwidgetcolorpicker.md#restorewidgetfromdata)
* [showPreloader](auwidgetcolorpicker.md#showpreloader)
* [showToast](auwidgetcolorpicker.md#showtoast)
* [togglePicker](auwidgetcolorpicker.md#togglepicker)

## Properties

###  color

• **color**: *any*

The color selected by the user.

___

###  params

• **params**: *[IColorPickerConfig](../interfaces/icolorpickerconfig.md)*

*Overrides [AuBaseWidget](aubasewidget.md).[params](aubasewidget.md#params)*

Properties of the widget.

## Accessors

###  _

• **get _**(): *boolean*

*Overrides [AuBaseSelectorWidget](aubaseselectorwidget.md).[_](aubaseselectorwidget.md#_)*

Returns the selected value.

**Returns:** *boolean*

## Methods

###  checkInitDependenciesWidgets

▸ **checkInitDependenciesWidgets**(): *string[]*

*Inherited from [AuBaseWidget](aubasewidget.md).[checkInitDependenciesWidgets](aubasewidget.md#checkinitdependencieswidgets)*

Returns an array of widget names, due to which the current widget cannot receive parameters.

**Returns:** *string[]*

___

###  clearSelection

▸ **clearSelection**(): *void*

*Overrides [AuBaseSelectorWidget](aubaseselectorwidget.md).[clearSelection](aubaseselectorwidget.md#abstract-clearselection)*

Sets the color value to `false` to reset the color selection.

**Returns:** *void*

___

###  closePicker

▸ **closePicker**(): *void*

Closes the color picker.

**Returns:** *void*

___

###  exportWidgetData

▸ **exportWidgetData**(`force`: boolean): *Promise‹ColorPickerData›*

*Implementation of [IRestorableWidget](../interfaces/irestorablewidget.md)*

**Parameters:**

Name | Type |
------ | ------ |
`force` | boolean |

**Returns:** *Promise‹ColorPickerData›*

___

###  resetPreloaderState

▸ **resetPreloaderState**(): *void*

*Inherited from [AuBaseWidget](aubasewidget.md).[resetPreloaderState](aubasewidget.md#resetpreloaderstate)*

**Returns:** *void*

___

###  restoreWidgetFromData

▸ **restoreWidgetFromData**(`widgetData`: ColorPickerData, `force`: boolean): *Promise‹void›*

**Parameters:**

Name | Type |
------ | ------ |
`widgetData` | ColorPickerData |
`force` | boolean |

**Returns:** *Promise‹void›*

___

###  showPreloader

▸ **showPreloader**(`isPreload`: boolean, `message`: string | string[], `timeout`: number): *void*

*Inherited from [AuBaseWidget](aubasewidget.md).[showPreloader](aubasewidget.md#showpreloader)*

Shows a preloader.

```
"onClick": [
  "{{#function main.showPreloader(true, 'Creating print files...')}}",
  "{{#function $["editor"].getHiResImages(800,800)}}",
  "{{#function main.showPreloader(false)}}"
]
```

**Parameters:**

Name | Type | Default | Description |
------ | ------ | ------ | ------ |
`isPreload` | boolean | - | If `true`, enables the preloader. |
`message` | string &#124; string[] |  [""] | A text message that appears next to the preloader.  |
`timeout` | number | 5 | - |

**Returns:** *void*

___

###  showToast

▸ **showToast**(`data?`: string, `duration?`: number): *void*

*Inherited from [AuBaseWidget](aubasewidget.md).[showToast](aubasewidget.md#showtoast)*

Shows a toast.

```
return editor.loadUserInfo(data)
    .catch(err => {
        this.widget.showToast("Error: Invalid data");
        console.log(err);
    });
```

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`data?` | string | A string message to display in the toast. |
`duration?` | number | Defines how long to show the toast for.  |

**Returns:** *void*

___

###  togglePicker

▸ **togglePicker**(): *void*

Shows and hides the color picker.

**Returns:** *void*
