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.

Get inspired by one of our real-life examples: Invoice or Sensor Readings

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

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 

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, like the status badge in this contract review.

data.jsonDownload
{
  "reference": "PA-2026-118",
  "reviewer": "Jane Smith",
  "term": "30 days",
  "highlight": "yellow",
  "status": {
    "label": "TO REVIEW",
    "color": "#983705",
    "background": "#FCEDB9"
  }
}
template.docxDownload
DOCX template of a contract review with a highlighted term and a gray status badge

Text of template.docx

CONTRACT REVIEW

Purchase agreement {d.reference}

Delivery clause, reviewed by {d.reviewer}

Clause 4.2

The supplier delivers the goods within {d.term} of the order.

Status

{d.status.label}

{bindColor(lightGray, color) = d.highlight}

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

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

report.docxDownload
Word contract review generated by Carbone with a yellow highlight and an amber status badge

Text of report.docx

CONTRACT REVIEW

Purchase agreement PA-2026-118

Delivery clause, reviewed by Jane Smith

Clause 4.2

The supplier delivers the goods within 30 days of the order.

Status

TO REVIEW

Loop with {bindColor}

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

data.jsonDownload
{
  "date": "November 10, 2026",
  "accounts": [
    {
      "customer": "Acme Corporation",
      "amount": "€12,400",
      "status": "Overdue",
      "color": "#FDE8E8"
    },
    {
      "customer": "Nova Logistics",
      "amount": "€8,950",
      "status": "Due in 5 days",
      "color": "#FEF3C7"
    },
    {
      "customer": "Orbit Analytics",
      "amount": "€3,200",
      "status": "Paid",
      "color": "#DCFCE7"
    }
  ]
}
template.docxDownload
DOCX template of an invoice table with a gray repeated row and a bindColor tag

Text of template.docx

ACCOUNTS RECEIVABLE

Open invoices

Balance on {d.date}

CUSTOMER

AMOUNT

STATUS

{d.accounts[i].customer}

{d.accounts[i].amount}

{d.accounts[i].status}

{d.accounts[i+1].customer}

{bindColor(e3e8ee, #hexa) = d.accounts[i].color}

report.docxDownload
Word invoice table generated by Carbone with one background color per row

Text of report.docx

ACCOUNTS RECEIVABLE

Open invoices

Balance on November 10, 2026

CUSTOMER

AMOUNT

STATUS

Acme Corporation

€12,400

Overdue

Nova Logistics

€8,950

Due in 5 days

Orbit Analytics

€3,200

Paid