Horizontal Rules
The hr element draws a horizontal rule with the rule's own keys, named as CSS names them where CSS has a name: line styles, horizontal alignment, filled color bars with an optional corner radius, spacing from its style's margins, and a borderColor that wins over color.
All properties are optional — { "hr": {} } renders a solid black 1pt rule spanning the full content width.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
height | number | 1 | Thickness in points |
width | number | full width | Horizontal extent in points. Omit to span the full content width. |
borderStyle | string | solid | Line style: solid, dashed, dashedFixed, dotted, double, roundDots, groove, ridge, inset, outset, none |
color | string | #000000 | Line color |
borderColor | string | — | Line color; wins over color |
backgroundColor | string | — | Fill of the rule's whole box, painted under its line. With borderStyle: "none" the rule is a plain bar; with a visible style the line is drawn over the fill |
borderRadius | number | 0 | Corner radius in points of the filled bar backgroundColor paints |
opacity | number | 1 | Transparency 0.0–1.0 |
style | string | — | Named style: its marginTop and marginBottom set the space around the rule (never less than half an em), and its color the line's where color is unset |
Line styles
Solid
A continuous unbroken line. The default.
{ "hr": { "height": 1, "color": "#334155" } }
Dashed
Evenly spaced dashes.
{ "hr": { "borderStyle": "dashed", "height": 1.5, "color": "#94A3B8" } }
Dotted
Evenly spaced small dots.
{ "hr": { "borderStyle": "dotted", "height": 1, "color": "#CBD5E1" } }
Round dots
Large round dots with generous spacing — decorative alternative to dotted.
{ "hr": { "borderStyle": "roundDots", "height": 2, "color": "#6366F1" } }
Double
Two parallel lines with a gap between them. height sets the total visual height across both lines and the gap.
{ "hr": { "borderStyle": "double", "height": 4, "color": "#0F172A" } }
Groove
A two-stripe engraved line using light and dark tones of color.
{ "hr": { "borderStyle": "groove", "height": 3, "color": "#64748B" } }
Ridge
A raised embossed line — the visual inverse of groove. Uses a light top stripe and a dark bottom stripe.
{ "hr": { "borderStyle": "ridge", "height": 3, "color": "#64748B" } }
Inset
A sunken line whose top edge is a darkened shade and bottom edge is a lightened shade of color.
{ "hr": { "borderStyle": "inset", "height": 3, "color": "#64748B" } }
Outset
A raised line — the visual inverse of inset. Top edge is lightened, bottom edge is darkened.
{ "hr": { "borderStyle": "outset", "height": 3, "color": "#64748B" } }
Dashed fixed
Like dashed but with a fixed dash-to-gap ratio independent of line length. Useful for consistent dash appearance across rules of different widths.
{ "hr": { "borderStyle": "dashedFixed", "height": 1, "color": "#94A3B8" } }
None
Renders no visible line — a pure vertical spacer, its height the margins of its style.
{
"document": {
"styles": { "spacer": { "marginTop": 12, "marginBottom": 12 } },
"content": [ { "hr": { "borderStyle": "none", "style": "spacer" } } ]
}
}
Alignment
When width is less than the content width, the rule's style places it with justifySelf, CSS Box Alignment's justify-self: start (the default), center, end, left or right.
{ "styles": { "centred": { "justifySelf": "center" }, "atEnd": { "justifySelf": "end" } } }
{ "hr": { "width": 80, "height": 3, "color": "#0F172A", "style": "centred" } }
{ "hr": { "width": 160, "height": 1, "color": "#94A3B8", "style": "atEnd" } }
Filled bars
A plain bar is backgroundColor with borderStyle: "none". With a visible line style, the line is drawn over the fill.
{
"hr": {
"height": 6,
"backgroundColor": "#3B82F6",
"borderStyle": "none"
}
}
Add borderRadius for rounded ends (PDF):
{
"hr": {
"height": 8,
"backgroundColor": "#6366F1",
"borderStyle": "none",
"borderRadius": 4,
"width": 200,
"style": "centred"
}
}
Spacing
With no style, a rule takes half an em above and below, as HTML gives <hr>, and that space collapses with its neighbours' margins. A style's marginTop and marginBottom widen it; a value under half an em leaves it at half an em.
{
"document": {
"styles": { "airy": { "marginTop": 16, "marginBottom": 16 } },
"content": [ { "hr": { "color": "#E2E8F0", "style": "airy" } } ]
}
}
Named styles
Define reusable rules in the document styles block and reference them with style. A style gives a rule its margins and its line color; the thickness and the fill are the rule's own keys.
{
"document": {
"styles": {
"sectionDivider": { "color": "#E2E8F0", "marginTop": 12, "marginBottom": 12 },
"accentBar": { "marginTop": 8, "marginBottom": 8 }
},
"content": [
{ "p": "Section One" },
{ "hr": { "style": "sectionDivider" } },
{ "p": "Section Two" },
{ "hr": { "height": 4, "backgroundColor": "#2563EB", "borderStyle": "none", "style": "accentBar" } },
{ "p": "Section Three" }
]
}
}
Styling a rule
Beyond its margins and colour, a rule's style places and bounds it as it does any block:
| Style key | What it does on a rule |
|---|---|
justifySelf | Where a rule narrower than its line stands: start, center, end, left, right |
marginLeft, marginRight | Shorten the line the rule spans: a rule with no width runs between them |
minWidth, maxWidth | Bound the rule's length, as they bound any block's width; a style's bound wins over the rule's own width |
breakBefore, breakAfter | Force or avoid a break before or after the rule: a page, a side (left, right, recto, verso), or a column in a flow of columns (see Page breaks) |
opacity, transform, rotate, clipPath | Paint the rule as they paint any block (see Paint) |
A width of 0 is a rule of no length, which draws nothing; only a rule with no width spans the whole line.
{
"document": {
"styles": {
"indented": { "marginLeft": 72, "marginRight": 72 },
"capped": { "maxWidth": 200, "justifySelf": "end" }
},
"content": [
{ "p": "Indented by an inch on each side:" },
{ "hr": { "style": "indented" } },
{ "p": "No longer than 200pt, at the end of the line:" },
{ "hr": { "style": "capped" } }
]
}
}
Rules in headers and footers
A header or a footer carries a rule of its own, header.hr or footer.hr, drawn along the band's edge nearest the page's content. It takes the same keys as a rule in the flow. With no color, and no style giving one, it is drawn in grey (#9CA3AF). See Headers and footers.
{
"header": {
"content": [ { "p": "Riverside Depot · Inspection report" } ],
"hr": { "borderStyle": "double", "height": 3, "width": 300, "style": "centred" }
}
}
Full document example
{
"document": {
"styles": {
"h2": { "fontSize": 14, "fontWeight": "bold", "color": "#0F172A", "marginTop": 16, "marginBottom": 4 },
"body": { "fontSize": 10, "color": "#334155" },
"divider":{ "color": "#E2E8F0", "marginTop": 10, "marginBottom": 10 },
"lead": { "marginBottom": 12 },
"closing":{ "marginTop": 20, "justifySelf": "center" }
},
"content": [
{ "p": "Annual Report 2025", "style": "h2" },
{ "hr": { "height": 3, "backgroundColor": "#1D4ED8", "borderStyle": "none", "style": "lead" } },
{ "p": "Highlights from the fiscal year.", "style": "body" },
{ "hr": { "style": "divider" } },
{ "p": "Financial Summary", "style": "h2" },
{ "p": "Revenue grew 18% year-over-year.", "style": "body" },
{ "hr": { "style": "divider" } },
{ "p": "Outlook", "style": "h2" },
{ "p": "We expect continued growth in Q1.", "style": "body" },
{ "hr": { "width": 80, "height": 3, "color": "#1D4ED8", "style": "closing" } }
]
}
}
Renderer notes
| Capability | DOCX | |
|---|---|---|
All borderStyle values | ✅ | ✅ (roundDots renders as square dots) |
backgroundColor plain bar (borderStyle: "none") | ✅ | ✅ |
backgroundColor under a visible line | ✅ | Reported: the line is written, the fill is not |
borderColor | ✅ | ✅ |
width + justifySelf | ✅ | ✅ |
borderRadius | ✅ | ✅ on a plain bar; reported in a Strict package or under a visible line |
opacity | ✅ | Reported, not drawn |
style margins (marginTop / marginBottom) | ✅ | ✅ |
Live example
All border styles, filled bars, alignment, and spacing options in one renderable document.
- Output
- Template
- Data