Design

Colors

Add a :color tag to text, a table cell, a row or a shape, and Carbone applies the color from your JSON data.
ENTERPRISE FEATURE Available for:
Carbone Cloud
Carbone On-premise
Embedded Carbone JS
  v4.0+ 

:color(scope, type)

v4.17.0+

Apply the color on the text, paragraph, table row or table cell

Params Description Type
scope Specifies the element to be color-changed
- p : the current paragraph where the tag is (by default)
- cell : the current cell of a table
- row : the current row of a table
- shape : the current shape
- part : for text section (the color is applied within the same styled of the element)
String
type Defines the property to be modified.
- text for the text color (by default)
- highlight to highlight the text
- background for cells, rows and shapes
- border for shapes only
String

Important Notes:

Compatible with PDF, ODT, ODP, DOCX, PPTX, HTML files.

Simple text color

The following example changes the text color to red:

data
{
  "flowerColor": "#FF0000"
}
template
Color of roses {d.flowerColor:color(p)}This paragraph is not colored.
Carbone Merge Icon
result
Color of roses This paragraph is not colored.

Condition and color

The following example changes the text color based on a condition.

Details:

data
{
  "test"      : "OK",
  "testError" : "ERROR",
  "success"   : "#007700",
  "error"     : "#FF0000"
}
template
The assessment passed
{d.test:ifEQ(OK):show(.success):elseShow(.error):color(p)}Error color
{d.testError:ifEQ(OK):show(.success):elseShow(.error):color(p)}
Carbone Merge Icon
result
The assessment passed
Error color

See the product roadmap slide with status colors example.

Loop and color

The example conditionally changes the text color of the current table row.

In the following example, the Carbone tag {d.tests[i].result:ifEQ(ok):show(#007700):elseShow(d.error):color(row, text)} is used in the template:

data
{
  "error": "#FF0000",
  "tests": [
    { "name": "Security Training","result": "ok" },
    { "name": "Code Auditing","result": "20 Vulnerabilities found" },
    { "name": "Firewall Testing","result": "ok" }
  ]
}
template
Testinfo{d.tests[i].name}{d.tests[i].result} {d.tests[i].result:ifEQ(ok):show(#007700):elseShow(d.error):color(row, text)}{d.tests[i+1]}
Carbone Merge Icon
result
TestinfoSecurity Trainingok Code Auditing20 Vulnerabilities found Firewall Testingok 

The temperature monitoring report colors each cell of its heat map with :color, on a scale relative to each asset.

Alternate row colors

Banded rows keep a long table readable. Write one tag in the repeated row, for example after the name in the first cell, to color every other row:

{d.products[i].name:print(.i):mod(2):ifEQ(1):show(#EEF2F7):elseShow(#FFFFFF):color(row,background)}

The tag prints nothing.

data.jsonDownload
{
  "company": "ACME SAS",
  "date": "2025-12-31",
  "products": [
    {
      "reference": "LAP-001",
      "name": "Laptop",
      "quantity": 12
    },
    {
      "reference": "MON-002",
      "name": "Monitor",
      "quantity": 24
    },
    {
      "reference": "KEY-003",
      "name": "Keyboard",
      "quantity": 42
    },
    {
      "reference": "MOU-004",
      "name": "Mouse",
      "quantity": 37
    },
    {
      "reference": "DOC-005",
      "name": "Docking station",
      "quantity": 15
    },
    {
      "reference": "WEB-006",
      "name": "Webcam",
      "quantity": 28
    },
    {
      "reference": "HEA-007",
      "name": "Headset",
      "quantity": 31
    },
    {
      "reference": "CAB-008",
      "name": "USB-C cable",
      "quantity": 64
    },
    {
      "reference": "SSD-009",
      "name": "External SSD",
      "quantity": 19
    },
    {
      "reference": "STA-010",
      "name": "Laptop stand",
      "quantity": 23
    }
  ]
}
template.docxDownload
DOCX template of a stock inventory with a repeated row and the alternate row colors tag

Text of template.docx

{d.company}

Stock inventory

As of {d.date:formatD(LL)}

PRODUCT

REFERENCE

QUANTITY

{d.products[i].name} {d.products[i].name:print(.i):mod(2):ifEQ(1):show(#EEF2F7):elseShow(#FFFFFF):color(row,background)}

{d.products[i].reference}

{d.products[i].quantity}

{d.products[i+1]}

report.docxDownload
Word stock inventory generated by Carbone with a light gray background on every other row

Text of report.docx

ACME SAS

Stock inventory

As of December 31, 2025

PRODUCT

REFERENCE

QUANTITY

Laptop

LAP-001

12

Monitor

MON-002

24

Keyboard

KEY-003

42

Mouse

MOU-004

37

Docking station

DOC-005

15

Webcam

WEB-006

28

Headset

HEA-007

31

USB-C cable

CAB-008

64

External SSD

SSD-009

19

Laptop stand

STA-010

23

Combined colors

The example conditionally changes the background color and text color of the table row.

Two tags are used in the following template:

data
{
  "error": "#ffd9d9",
  "tests": [
    { "name": "Security Training","result": "ok" },
    { "name": "Code Auditing","result": "20 Vulnerabilities found" },
    { "name": "Firewall Testing","result": "ok" }
  ]
}
template
Testid{d.tests[i].name}{d.tests[i].result} {d.tests[i].result:ifEQ(ok):show(#000000):elseShow(#d90000):color(row, text)} {d.tests[i].result:ifEQ(ok):show(#FFFFFF):elseShow(d.error):color(row, background)}{d.tests[i+1]}
Carbone Merge Icon
result
TestidSecurity Trainingok  Code Auditing20 Vulnerabilities found  Firewall Testingok  

Color Text Section

Compatible with PDF and ODT files for the moment.

The :color formatter includes a part argument, which allows you to apply color to a specific section within a paragraph. This feature is particularly useful when you need to highlight certain parts of your text without affecting the entire paragraph.

To correctly use the :color(part) formatter, follow these steps:

  1. Tag Placement: Place the tag with the :color(part) formatter right next to the text you want to color.
  2. Selecting Tags: In LibreOffice or MS Word, select the tags you want to color, including the tag containing the :color(part) formatter.
  3. Clear Style : Click on the "Clear Direct Formatting" icon located in the "Home" tab. This will define the section to be colored for the :color(part) formatter.
  4. Reapply Font Style: If you had a specific font style, reapply it after clearing the direct formatting.

Color replacement {bindColor}

We recommend the :color formatter instead of {bindColor}: it is simpler and less error-prone. {bindColor} is the former way to manage colors in Carbone.

Compatible with PDF, ODT, ODP, DOCX, and ODS files.

The {bindColor} tag replaces a color of the template with a color from the data:

{bindColor(myColorToBind, myFormat) = d.myVar}

Write the tag anywhere in the document: at the end, in the header or footer, or below the [i+1] row of a loop, even if d.myVar belongs to the loop. Carbone removes the tag from the report. You can bind each reference color only once.

Supported elements:

Simple example with {bindColor}

In this project status, the status badge uses two reference colors: #3C4257 for the text and #E3E8EE for the background. The priority uses #8792A2. The three tags at the end of the template replace them with the colors from the data.

data.jsonDownload
{
  "project": "Website redesign",
  "owner": "Jane Smith",
  "due": "December 15, 2026",
  "status": {
    "label": "ON TRACK",
    "color": "#0E6245",
    "background": "#CBF4C9"
  },
  "priority": {
    "label": "High",
    "color": "#C0123C"
  }
}
template.odtDownload
ODT template of a project status with a gray status badge and three bindColor tags

Text of template.odt

PROJECT STATUS

{d.project}

Weekly update, owner {d.owner}

Status

{d.status.label}

Priority

{d.priority.label}

Due date

{d.due}

{bindColor(3c4257, #hexa) = d.status.color}

{bindColor(e3e8ee, #hexa) = d.status.background}

{bindColor(8792a2, #hexa) = d.priority.color}

report.odtDownload
Project status generated by Carbone with a green status badge and a red priority

Text of report.odt

PROJECT STATUS

Website redesign

Weekly update, owner Jane Smith

Status

ON TRACK

Priority

High

Due date

December 15, 2026

Color formats for {bindColor}

Format Value of d.myVar
#hexa "#FF0000"
hexa "FF0000"
color "red", one of the color names below
rgb { "r": 255, "g": 0, "b": 0 }, each value from 0 to 255
hsl { "h": 0, "s": 100, "l": 50 }, h from 0 to 360, s and l from 0 to 100, or all three from 0 to 1

The color format accepts 17 names:

yellow    | green     | cyan      | magenta     | blue     | red
darkBlue  | darkCyan  | darkGreen | darkMagenta | darkRed  | darkYellow
darkGray  | lightGray | black     | white       | transparent

Microsoft Word exception for {bindColor}

In Microsoft Word, a text highlight accepts only a color name. Apply a highlight color in the template, then use its name as the reference color with the color format, for example {bindColor(lightGray, color) = d.highlight}. All the names above work except transparent.

Text colors, cell backgrounds and text shading (Borders and Shading > Shading) accept hexadecimal colors.

Loop with {bindColor}

Apply the reference color to the cells of the repeated row, then bind it to the color of the current item, like {bindColor(e3e8ee, #hexa) = d.accounts[i].color}. Each row gets its own color. You can write the tag below the loop.