Skip to content
Strife Docs

Reference Fields

Color

The Color field lets editors pick one color from a palette the template defines. It stores the color's hex code.

The Color field lets editors pick one color from a fixed palette, such as the color of a heading. Each color has a name, which editors see, and a hex code, which is what the field stores. There is no free color picker.

The field shows the chosen color and its name. Clicking it opens the palette, where pointing at a color shows its name. The x clears the field.

Settings

The template designer lists a Color field with the basic settings, but doesn't offer it under Add field and has no setting for the palette. Define the field in JSON, or with fields.color().

Note:

You can find a comprehensive list of all basic settings in the 'Overview' section.

Define with JSON

When defining templates using JSON, this field is represented using:

  • Component Name: str-color
  • Type: color
  • Reference ID: str-color
JSON
{
  ...
  "editor": {
    "name": "str-color",
    "type": "color",
    "propertyName": "headingColor",
    "options": {
      "items": [
        { "name": "White", "value": "#FFFFFF" },
        { "name": "Yellow", "value": "#FFD200" }
      ]
    }
  }
}

Each item's name is what editors see, and its value is the hex code that is stored: #RGB, #RGBA, #RRGGBB or #RRGGBBAA. List each code once. A field without items has no palette to open, and says so.

Stored value

ChoiceStored
A color
"#FFD200", the code as the palette writes it
Nothing (cleared)
null

The field isn't localizable: one color is shared by every language, and it is never sent for translation.

Define with the schema DSL

fields.color() compiles to this editor.