codly.header
Creates a configurable header element for a Codly code block.
Signature
// Create a header element
codly.header(
body,
repeat: false,
align: center + horizon,
inset: auto,
fill: luma(240),
stroke: auto
)
// Equivalent set-rule for `codly.header`
codly.header-set_(..fields)
// Equivalent show rule for `codly.header`
codly.header-show_(it => ...)
body is required and positional; all other fields are named.
Fields
| Field | Type | Default / required | Meaning |
|---|---|---|---|
body |
none | content |
Required, positional | Content displayed above the code rows. |
repeat |
none | bool |
false |
Whether the header repeats when the block spans multiple pages. |
align |
none | alignment |
center + horizon |
Alignment of the header cell content. |
inset |
none | length | dictionary | auto |
auto |
Header cell padding; auto inherits the grid inset. |
fill |
none | paint | auto |
luma(240) |
Header cell background, independent of code and number fills. none leaves it unfilled; auto uses the default header fill. |
stroke |
none | stroke | auto |
auto |
Header cell border; auto inherits the grid stroke. |
Behavior
When used by codly.new, the header cell spans the code block’s columns. repeat controls the underlying grid header’s repetition. Setting fill to auto resolves to luma(240); the header fill is independent of line and number fills. The block’s outer corner radius is configured on codly.new, not on the header element.
codly.header-set_(..fields) sets defaults for headers in scope; codly.header-show_(replacement) installs a scoped replacement, whose callback receives the header element as it.
Example
#import "@preview/codly:2.0.0" as codly
#codly.new(
```py
print('hello')
```,
header: codly.header([*Greeting* · Python], fill: example-fill, inset: 5pt),
radius: example-radius,
)
Edit & run on your device
The controls supply the example variables. Their definitions are hidden here; Copy code includes the current values and your edits.