A Color input lets your team members store color information in your data files or the front matter of markup files. Color inputs have a color picker with spectrum and transparency controls for editing color values.
For each input, you can configure the format of the color value, enable transparency controls, and determine how CloudCannon handles empty values. You can also use the general configuration options available for all inputs.
Color#
The Color input provides an editing interface for color values.
You can configure a Color input using the type
key with the value color
. Define the type
key under your input key name within _inputs
. For more information, please read our documentation on configuring your inputs.
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.
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.
Once configured, the Color input will appear in the Data Editor or the Visual or Content Editor sidebar when you add it to a data file or the front matter of a markup file.
Options#
You can configure Color inputs using the options
key under your input key, inside of _inputs
.
Color inputs have the following options available:
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.
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.
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.
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.