Fields

Color

Last updated

A screenshot of a color field in the Page Builder.

A color field in the Page Builder.

The color field allows content writers to select a color. The field is displayed as a color picker in the Page Builder.

The color is saved as a hex value, like #FFFFFF.

Color field values can be used anywhere hex color values are supported.

<span style={{ color: slice.primary.text_color }}>Hello!</span>

Add a color field to a content model

Color fields are added using the Type Builder, a tool for building by hand, or the Prismic CLI, a tool for AI agents.

Use color fields

Color fields can be used anywhere hex color values are supported.

In this example, the text_color field determines the <span>’s color.

<span style={{ color: slice.primary.text_color }}>Hello!</span>

Check if a color field has a value

Use isFilled.color() from @prismicio/client to check if a color field has a value.

import { isFilled } from "@prismicio/client";

if (isFilled.color(slice.primary.my_color_field)) {
  // Do something if `my_color_field` has a value.
}

Learn more about isFilled

API response

Here is what a color field looks like from the Content API:

{
  "example_color": "#5B295F"
}
Was this page helpful?