Skip to content

Styles and conditions

Property Values
fontFamily Helvetica, Times, Courier, or a registered font
fontSize points
fontWeight / fontStyle normal, bold / normal, italic
textDecoration none, underline, line-through
color / backgroundColor #rgb, #rrggbb, #rrggbbaa, rgb(), rgba() or transparent
textAlign left, center, right, justify
verticalAlign top, middle, bottom
direction auto (default: the first strong letter decides), ltr, rtl. Right-to-left text is right-aligned unless textAlign is set
padding one number, or { top, right, bottom, left }, in template units
border { width, color, style, sides }: width in points, style is solid, dashed or dotted, sides is a list of top, right, bottom, left (default all)

Lines take their width, color and dash from border. Rectangles are filled with backgroundColor and outlined with border.

Define styles once in styles and refer to them by name. A component’s own style is applied on top:

{
"styles": { "th": { "fontWeight": "bold", "color": "#fff", "backgroundColor": "#334155", "padding": 1.5 } },
"body": [{ "kind": "band", "id": "b", "height": 7, "components": [
{ "id": "h", "type": "text", "x": 0, "y": 0, "width": 40, "height": 7, "styleName": "th", "style": { "textAlign": "right" }, "text": "Total" }
]}]
}

In the designer, Save as style turns a component’s style into a named one.

conditions apply extra styles when an expression is true. Matching conditions are applied in order, after the named style and the inline style:

{
"id": "status", "type": "text", "text": "{{ upper(row.status) }}",
"conditions": [
{ "expression": "row.status === 'paid'", "style": { "color": "#15803d", "backgroundColor": "#dcfce7" } },
{ "expression": "row.status === 'overdue'", "style": { "color": "#b91c1c", "backgroundColor": "#fee2e2" } }
]
}
viewer-conditional.tsx
import { ReportViewer } from '@ariana-reports/react';
import { invoicesData, invoicesTemplate } from './report-data';
export default function ViewerConditional() {
return <ReportViewer template={invoicesTemplate} data={invoicesData} zoomMode="fitWidth" />;
}

visible on a component or a band is an expression. When it is falsy, the component or the whole band is skipped, and a band that is skipped takes no space:

{ "id": "note", "type": "text", "text": "Out of stock", "visible": "row.stock === 0" }