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.
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
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:
- 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
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)}- :print(.i) returns the position of the row in the list, starting at 0.
- :mod(2) returns the remainder of the division by 2:
0for the 1st, 3rd, 5th row, and1for the 2nd, 4th, 6th row. - :ifEQ(1) with :show and :elseShow returns light gray for the 2nd, 4th, 6th row and white for the others.
- :color(row,background) applies this color to the background of the whole row.
The tag prints nothing.
{
"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
}
]
}
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]}

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:
{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.
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.