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.
- The color provided must be in 6-digit hex color notation, with or without a hashtag, and can be in lowercase or uppercase:
#FF0000orFF0000. Carbone replaces incorrect color values with light gray (#888888). - The
:colorformatter manages priority between overlapping areas. A color applied to the current paragraph has a higher priority than a color applied to the current shape, cell, or row. - For HTML, the color is applied using the
styleattribute only to the selected HTML tag (tr,td,p). - For ODP (text, tables, and shapes) and ODT (shapes only), the
:colorformatter requires that a non-default style is already applied to the target element in the template (e.g., a custom text color). - For PPTX, all combinations of
type(background,text,border) andscope(row,cell,shape) are supported, exceptborderwhich applies only to shapes. Available since v5.6.0. - Complex nested tables with colors on sub-tables are not fully supported.
highlightis not managed in DOCX templates.- The
:colorformatter cannot be used in aliases and cannot be combined with aggregators. - The
:color(part)feature is currently available only for ODT templates.
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:
{
"flowerColor": "#FF0000"
}
Color of roses {d.flowerColor:color(p)}This paragraph is not colored.
Color of roses This paragraph is not colored.
Condition and color
The following example changes the text color based on a condition.
Details:
- If the
testvalue is equal to "OK," the text color will bed.success(color "#007700"). - If the
testvalue is not equal to "OK," the text color will bed.error(color "#FF0000"). - The
:color(p)formatter applies the color to the text in the current paragraph.
{
"test" : "OK",
"testError" : "ERROR",
"success" : "#007700",
"error" : "#FF0000"
}
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)}
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:
- If the
resultvalue is equal to "ok," the text color will change to green (#007700). The argument passed is a string, not a value sourced from the JSON. - If the
resultvalue is not equal to "ok," the color will bed.error. - The
:color(row, text)formatter changes the text color in the current row.
{
"error": "#FF0000",
"tests": [
{ "name": "Security Training","result": "ok" },
{ "name": "Code Auditing","result": "20 Vulnerabilities found" },
{ "name": "Firewall Testing","result": "ok" }
]
}
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]}
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:
{d.tests[i].result:ifEQ(ok):show(#000000):elseShow(#FFFFFF):color(row, text)}: Ifresultis equal took, the text color of the current row is changed to black (#000000); otherwise, it changes to white (#FFFFFF).{d.tests[i].result:ifEQ(ok):show(#FFFFFF):elseShow(d.error):color(row, background)}: Ifresultis equal took, the row keeps a white background (#FFFFFF); otherwise, it takes the red color sourced from the JSON (d.error).
{
"error": "#ffd9d9",
"tests": [
{ "name": "Security Training","result": "ok" },
{ "name": "Code Auditing","result": "20 Vulnerabilities found" },
{ "name": "Firewall Testing","result": "ok" }
]
}
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]}
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:
- Tag Placement: Place the tag with the
:color(part)formatter right next to the text you want to color. - Selecting Tags: In LibreOffice or MS Word, select the tags you want to color, including the tag containing the
:color(part)formatter. - 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. - 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}
myColorToBind: the reference color, a hexadecimal color applied in the template. It is case-insensitive, and the leading#is optional. Carbone replaces this color on every element that uses it, so pick a color that appears nowhere else in the template. Text highlights in Microsoft Word are an exception.myFormat: the format of the new color in the data.d.myVar: the new color.
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:
- Text colors, text backgrounds and table cell backgrounds.
- DOCX only: shape backgrounds and line colors. Write the tag in the document body, not in the alternative text of the shape, and give the shape an RGB color in the template, not a theme color.
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.
{
"project": "Website redesign",
"owner": "Jane Smith",
"due": "December 15, 2026",
"status": {
"label": "ON TRACK",
"color": "#0E6245",
"background": "#CBF4C9"
},
"priority": {
"label": "High",
"color": "#C0123C"
}
}
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}

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 | transparentMicrosoft 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.
{
"reference": "PA-2026-118",
"reviewer": "Jane Smith",
"term": "30 days",
"highlight": "yellow",
"status": {
"label": "TO REVIEW",
"color": "#983705",
"background": "#FCEDB9"
}
}
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}

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.
{
"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"
}
]
}
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}

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