Reference
Background
Drawn behind each PDF page's content, the size of the page: a cover, a band, a full-bleed picture.
Background(on: Enum) { … }
Since 5.2.0
on
all
first
rest
odd
even
No preview for this one: the example below shows how it is written.
Example
Document(title: "Q3 report") {
Background(on: .first) {
Stack { style { height: 100%; background: linear-gradient(160deg, #0B1220, #1E3A8A) } }
}
Stack {
style { color: #ffffff; padding-top: 240px }
Heading("Q3 report").h1
Text("Northwind Ltd · October 2026")
}
}
A band down every page's side
Document(title: "Handbook") {
Background { Stack { style { width: 24px; height: 100%; background: #0F766E } } }
Heading("Handbook").h1
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
on: | one of its cases |
| Which pages it is drawn on, behind the content, edge to edge. Written as a flag,
|
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.all
.first
.rest
.odd
.even
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
children
Renders with the class wf-background, stable across releases, so a stylesheet may target it.
Codes this can raise
These controls list the props' cases; the example below shows them written.