The Color field creates a color picker that can be used in your block template.

Click image to enlarge
- Field Label: The field label will be displayed next to the field when adding it the block to the post or page.
- Field Name: The field name should auto-fill based on the field label, but can be customized. This will be used in the PHP as part of the block template.
- Field Type: Choose the Color field type.
- Field Location: Choose a location to display the field.
- Editor will show the field in the main editing area of a post or page.
- Inspector will display the field in the right-hand sidebar under the block inspector.
- Field Width: Select how widely the field should be displayed.
- Help Text: Enter instructions to describe the data needed in the field. (optional).
- Default Value: The default value for this field when adding the block. You can use either a hex value (
#FF00FF) or an rgba value(rgba(255, 0, 255, 0.5)).
PHP API Controls
- name
- label
- control
- type
- order
- location
- width
- help
- default
Template Usage
To use the Color field in your template, use the field name you provided.
There are two ways you can do this.
- Template Editor: Using the built-in template editor is the easiest way to create the required block template. The template editor accepts HTML markup, field names (enclosed in 2 brackets), and CSS only.
Here’s an example of HTML you can use in the template editor:
<div style="background:{{block-background-color}}"></div>
- PHP Template: If you need to use logic, loop syntax, define variables, or use PHP, you can create the template manually using the PHP templating method instead.
For example:
<div style="background:<?php block_field( 'block-background-color' ); ?>"></div>
The API will return a string. It will be either a hex value (#FF00FF) or an RGBA value (rgba(255, 0, 255, 0.5)).
Example template file /blocks/block-example.php
<?php
// Example Color Field
?>
<div style="background:<?php block_field( 'block-background-color' ); ?>">
<p style="color:white;text-align:center;">I chose this background color using Genesis Custom Blocks.</p>
</div>
Block Usage
To use the block with the Color field on your site, locate it in the blocks menu.

Click image to enlarge
It will then display within your post or page editor.

Click image to enlarge
You can enter a hex code or an RGBA value into the field or you can click on the color circle to open up the color picker. You can switch between hex and RGBA options by clicking the caret next to the field.

Click image to enlarge
It will also display on the front end of your site.

Click image to enlarge
