Allows users to select from a pallete of swatches, or add their own using a color picker
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
props | object | Component props. Properties
| ||||||||||||||||||||||||||||||||||||
ref | object | | Ref to the component. |
- Since
- 1.1.15
- Source
The Swatch component.
- Type:
- JSX.
Element
import Swatch from '@gravityforms/components/react/admin/modules/Swatch';
return (
<Swatch customClasses={ [ 'example-class' ] } palette={ [ '#000', '#111' ] } />
);
Methods
(inner) handleColorChange(event) → {void}
Handler for the color change event.
Name | Type | Description |
---|---|---|
event | object | Event object. |
- Since
- 1.1.15
- Source
- Type:
- void
(inner) handlePickerCancel() → {void}
Handler for the cancel event on the swatch.
- Since
- 1.1.15
- Source
- Type:
- void
(inner) handlePickerDelete(index) → {void}
Handler for the delete event on the swatch.
Name | Type | Description |
---|---|---|
index | number | Index of the swatch palette. |
- Since
- 1.1.15
- Source
- Type:
- void
(inner) handlePickerSave(swatch) → {void}
Handler for the save event on the swatch.
Name | Type | Description |
---|---|---|
swatch | string | The swatch value. |
- Since
- 1.1.15
- Source
- Type:
- void
(inner) renderAddNewSwatchOption() → {JSX.Element}
Render the add new swatch option.
- Since
- 1.1.15
- Source
The add new swatch option.
- Type:
- JSX.
Element
(inner) renderSwatchOption(swatch, index, isCustom) → {JSX.Element}
Render the swatch option.
Name | Type | Description |
---|---|---|
swatch | string | The swatch value. |
index | number | The index of the swatch palette. |
isCustom | boolean | Whether the swatch is custom or not. |
- Since
- 1.1.15
- Source
The swatch option.
- Type:
- JSX.
Element