A Color input is an editing interface for color information. By configuring your inputs, you can customize the appearance and functionality for a better editing experience.

These instructions assume that you know where in the configuration cascade you want to configure your input. For more information, please read our documentation on Color inputs, inputs in general, and the configuration cascade.
To configure a Color input:
- Open your website files in your local development environment, or log in to CloudCannon and select the Site for which you want to configure your input.
- Navigate to the location in the configuration cascade where you want to configure your input. This can be the root of your CloudCannon Configuration File, within the
collections_config.*
key in your CloudCannon Configuration File, a Schema file, a markup file, or any where you configure a Structure. - Identify the
_inputs
key, or create one at that level of the configuration cascade. - Add an input name key for your input under the
_inputs
key (a.k.a.,_inputs.*
). We recommend naming your input something simple that indicates the function or context. - Add the
type
key under your input name key, with the valuecolor
. - (Optional.) Add any other general configuration keys (e.g.,
label
,comment
,context
) under your input name key. - (Optional.) Add any specific configuration keys under
_inputs.*.options
(e.g.,format
,alpha
).
CloudCannon will now apply this input configuration to all markup files that use your input name key, without needing to save your configuration. This allows you to make changes to your input configuration and see those changes affect inputs live.
When you are happy with your input configuration, you must save your input configuration.
_inputs:
gradient_stop:
type: color
All inputs are defined under the _inputs
key, regardless of where they are in the configuration cascade.
This Color input is called gradient_stop
.
The value of the type
key determines the input type. This is a color
input.
{
"_inputs": {
"gradient_stop": {
"type": "color"
}
}
}
All inputs are defined under the _inputs
key, regardless of where they are in the configuration cascade.
This Color input is called gradient_stop
.
The value of the type
key determines the input type. This is a color
input.
When you add your input key name to a data or markup file, your configured Color input will appear in the Data Editor, Visual Editor, or Content Editor.
---
gradient_stop: rgb(3, 74, 216)
---
Blog content goes here.
Input configuration options#
General configuration options are available for all input types. You can define the label, comment, and context box for your Color input, whether it is hidden or disabled, and how CloudCannon should handle configuration at multiple levels of the configuration cascade.
Specific configuration options for Color inputs include defining the format of a color value, enabling transparency controls, and how CloudCannon handles empty values. You can also add input validation to require a value, specify the minimum and maximum value length, or match a regular expression.
Here is an example of a Color input using some of the most commonly used configuration keys.
_inputs:
background:
type: color
label: Background Color
comment: Select the color for the background of this page.
options:
format: hex
required: true
pattern: ^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
pattern_message: Please enter a valid HEX format.
{
"_inputs": {
"background": {
"type": "color",
"label": "Background Color",
"comment": "Select the color for the background of this page.",
"options": {
"format": "hex",
"required": true,
"pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",
"pattern_message": "Please enter a valid HEX format."
}
}
}
}
For a complete list of configuration keys available for inputs please read our inputs reference documentation.
These keys configure the appearance and functionality of Color inputs in CloudCannon.
This key determines what format the color picker uses. Does not update existing values. Defaults to follow the input naming convention, or hex
.
Value must be one of rgb
, hex
, hsl
or hsv
.
This key toggles the transparency controls for the color picker. Defaults to follow the input naming convention.
This key determines how CloudCannon handles an empty value. This key does not apply to existing empty values.
Value must be one of the following:
string
- an empty value for this input will be stored as""
.null
- an empty value for this input will be stored as a null value (default). This does not apply to TOML files.
This key toggles whether CloudCannon requires this Input to have a value. If set to true
, CloudCannon will require you to enter a value to save your changes, or discard your unsaved changes.
By default, this key is false
(i.e, CloudCannon does not require this Input to have a value).
This key is available for Array, Boolean, Code, Color, File, Number, Object, Select and Multiselect, Text, Rich Text, and URL Inputs.
Show exampleHide example
In this example, we want to require our team to enter an author
value for markup files with this Input.
_inputs:
author:
type: text
comment: Enter the name of the author for this blog post.
options:
required: true
{
"_inputs": {
"author": {
"type": "text",
"comment": "Enter the name of the author for this blog post.",
"options": {
"required": true
}
}
}
}
This key defines the maximum string length, in characters, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too long. If the Input already contains a longer value, CloudCannon will require you to remove characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
Value can be any non-negative integer. If this key is set to 0
, CloudCannon requires the Input to be empty. If options.min_length
is also configured, this key cannot be a smaller number.
This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs. To use this key in a Select Input, allow_create
must be set to true
.
Show exampleHide example
In this example, we want our team to enter a blog description using the Rich Text seo_description
Input. This Input limits you to a maximum of 125 characters.
_inputs:
seo_description:
type: markdown
comment: Enter a brief description of this blog.
options:
max_length: 125
min_length: 25
{
"_inputs": {
"seo_description": {
"type": "markdown",
"comment": "Enter a brief description of this blog.",
"options": {
"max_length": 125,
"min_length": 25
}
}
}
}
This key defines the minimum string length, in characters, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too short. If the Input already contains a shorter value, CloudCannon will require you to add characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
Value can be any positive integer. If options.max_length
is also configured, this key cannot be a greater number.
This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs. To use this key in a Select Input, allow_create
must be set to true
.
Show exampleHide example
In this example, we want our team to enter a blog description using the Rich Text seo_description
Input. This Input requires a minimum of 25 characters.
_inputs:
seo_description:
type: markdown
comment: Enter a brief description of this blog.
options:
max_length: 125
min_length: 25
{
"_inputs": {
"seo_description": {
"type": "markdown",
"comment": "Enter a brief description of this blog.",
"options": {
"max_length": 125,
"min_length": 25
}
}
}
}
This key defines a regular expression that the Input value must match. When configured, CloudCannon will require you to enter a value that matches the REGEX pattern. If the Input already contains an invalid value, CloudCannon will require you to enter a valid string to save your changes, or discard your unsaved changes.
Value must be a valid REGEX string.
This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs. To use this key in a Select Input, allow_create
must be set to true
.
Show exampleHide example
In this example, we want our team to add an email address to the contact_email
Input using the correct email format.
_inputs:
contact_email:
type: email
options:
pattern: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
pattern_message: Please use the format ___@___.__
{
"_inputs": {
"contact_email": {
"type": "email",
"options": {
"pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
"pattern_message": "Please use the format ___@___.__"
}
}
}
}
This key defines the message that explains which regular expression an Input will accept. This key requires you to define options.pattern
.
This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.
Show exampleHide example
In this example, we prompt our team to use the correct email format in the contact_email
Input using a pattern message.
_inputs:
contact_email:
type: email
options:
pattern: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
pattern_message: Please use the format ___@___.__
{
"_inputs": {
"contact_email": {
"type": "email",
"options": {
"pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
"pattern_message": "Please use the format ___@___.__"
}
}
}
}
Valid values#
Here are some examples of valid values for the key color
.
Empty/null value:
color:
Any valid CSS color name (quoted or unquoted):
color: blue
color: "blue"
Quoted hexadecimal color (case insensitive):
color: "#034AD8"
color: "#034ad8"
color: "#034AD8FF"
RGB and RGBA (quoted or unquoted):
color: rgb(3, 74, 216)
color: "rgb(3, 74, 216)"
color: rgba(3, 74, 216, 0.5)
color: "rgba(3, 74, 216, 0.5)"
HSL and HSLA (quoted or unquoted):
color: hsl(220, 97.3, 42.9)
color: "hsl(220, 97.3, 42.9)"
color: hsla(220, 97.3, 42.9, 0.5)
color: "hsla(220, 97.3, 42.9, 0.5)"
HSV and HSVA (quoted or unquoted):
color: hsv(220, 98.6, 84.7)
color: "hsv(220, 98.6, 84.7)"
color: hsva(220, 98.6, 84.7, 0.5)
color: "hsva(220, 98.6, 84.7, 0.5)"
Any valid CSS color name:
color = "blue"
Hexadecimal color (case insensitive):
color = "#034AD8"
color = "#034ad8"
color = "#034AD8FF"
RGB and RGBA:
color = "rgb(3, 74, 216)"
color = "rgba(3, 74, 216, 0.5)"
HSL and HSLA:
color = "hsl(220, 97.3, 42.9)"
color = "hsla(220, 97.3, 42.9, 0.5)"
HSV and HSVA:
color = "hsv(220, 98.6, 84.7)"
color = "hsva(220, 98.6, 84.7, 0.5)"
Empty/null value:
"color": null
Any valid CSS color name:
"color": "blue"
Hexadecimal color (case insensitive):
"color": "#034AD8"
"color": "#034ad8"
"color": "#034AD8FF"
RGB and RGBA:
"color": "rgb(3, 74, 216)"
"color": "rgba(3, 74, 216, 0.5)"
HSL and HSLA:
"color": "hsl(220, 97.3, 42.9)"
"color": "hsla(220, 97.3, 42.9, 0.5)"
HSV and HSVA:
"color": "hsv(220, 98.6, 84.7)"
"color": "hsva(220, 98.6, 84.7, 0.5)"
CloudCannon may alter your input value under the following circumstances:
- Hex colors with an alpha value will be converted to
rgba
. - Colors will be converted to the specified
format
input option when loaded in the Data Editor. - Quotes will be stripped from non-hex colors when loaded in the Data Editor.
Unconfigured Color inputs#
In some cases, CloudCannon can still detect a Color input even if you have not configured it.
CloudCannon will interpret any unconfigured input with the key name color
, colour
, rgb
, rgba
, hex
, hsv
, hsva
, hsl
, or hsla
, or that ends in _color
, _colour
, _rgb
, _rgba
, _hex
, _hsv
, _hsva
, _hsl
, or _hsla
, as a Color input. Key name variations ending with "a" will enable the alpha
option automatically.
---
main_hex: "#034AD8"
---
Content goes here.
This behavior is convenient if you have simple inputs or do not want to configure inputs. It is also beneficial for new websites on CloudCannon where you have yet to create any CloudCannon-specific configuration.
We recommend configuring your inputs for greater control over their functionality and appearance.