Color Set
The Color Set allows users to select a color from a predefined palette of colors.

Demonstration
Handy::control( 'color-set', [
'id' => 'color_set_id',
'section' => 'layout_section',
'label' => esc_html__( 'Color Set Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'priority' => 1,
'colors' => [ '#000000', '#ffffff', '#eeeeee' ]
]);
TIP
Here's an example using the default parameter. Note the default value must exist in defined colors.
Handy::control( 'color-set', [
'id' => 'color_set_id',
'section' => 'layout_section',
'default' => '#000000',
'label' => esc_html__( 'Color Set Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'priority' => 1,
'colors' => [ '#000000', '#ffffff', '#eeeeee' ]
]);
TIP
Here's an example using the shape and size parameters. Note the shape value accepts only round or square, while size value accepts only a valid size with unit.
Handy::control( 'color-set', [
'id' => 'color_set_id',
'section' => 'layout_section',
'default' => '#000000',
'label' => esc_html__( 'Color Set Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'priority' => 1,
'shape' => 'round',
'size' => '25px',
'colors' => [ '#000000', '#ffffff', '#eeeeee' ]
]);
TIP
Here's an example of using the utility __get_material_colors() as a color palette in colors. For further information on the utilities, please read Utilities.
// The Handy::__get_material_colors( 'all' )
// returns all the available material colors.
Handy::control( 'color-set', [
'id' => 'color_set_id',
'section' => 'layout_section',
'label' => esc_html__( 'Color Set Control', 'textdomain' ),
'description' => esc_html__( 'Description Here', 'textdomain' ),
'priority' => 1,
'colors' => Handy::__get_material_colors( 'all' )
]);
Basic Usage
// Return a string.
$value = get_theme_mod( 'color_set_id' );
Parameters
| Name | Description |
|---|---|
| id |
The unique slug like string used as an ID and also as an index name in storing data in a database. |
| section |
The ID of the section in which the control will be displayed. |
| default |
The predetermined value of the control. Accepts value only from defined |
| colors |
The array-based list of predetermined options or colors. |
| shape |
The color set's visual shape. Accepts only |
| size |
The color set's width and height. Accepts only a valid size with unit. Default |
| label |
The label or title of the control to show in the UI. Default empty. |
| description |
The description of the control to show in the UI. Default empty. |
| priority |
The order of control appears in the section. Default |
| validations |
The set of validations used to validate the value of the control. For further details, read validations. Default empty. |
| active_callback |
A callback function that determines the visibility of a control, whether to show or hide depending on a condition. For further details, read active_callback. Default empty. |
| sanitize_callback |
A callback function that sanitizes the value of control before storing it in the database. Note that this is only optional since each control is already well sanitized. For further details, read sanitize_callback. Default empty. |