Styling
Style is written on the element it affects. There are no stylesheets, no selectors, no class names and therefore no cascade. An element's appearance depends on that element, the document's defaults, and nothing else.
<p color="navy" letter-spacing={0.5} align="center">…</p>
<p color="rgb(255 0 128 / 50%)">…</p>
<page size="A4" flow>…</page>
Where a value comes from
Three sources, one level deep:
- what the tag states;
- a default keyed by tag name in the project file (
element.h1); - the engine's fixed value.
Exactly one origin per property. That is what makes “no unexplained layout” checkable. A property stated twice on one element is not resolved by specificity — there is no second rule to compare against.
{
"element": {
"p": { "font-size": 9.5, "leading": 1.35, "align": "justify" },
"h1": { "font-size": 18, "leading": 1.1 },
"caption": { "font-size": 8, "leading": 1.25 }
}
}
A tag's own attribute beats the project default. Nothing inherits from a
container: a <col> cannot set a font size for its children.
Value forms
| Written | Meaning |
|---|---|
name="text" | A string literal |
name={expression} | An expression: number, bool, identifier, object or array |
name | Boolean true |
name={…} /> | A self-closing element |
Strings use double quotes. Expressions are the small expression language from Components; there is no arithmetic.
Properties by tag
Text blocks — p, h1–h6, caption
| Property | Value |
|---|---|
font-size | Points (ignores unit) |
leading | A multiple of the font size |
align | left, center/centre, right, justify |
color | Any sRGB colour |
font-family | A declared family |
font-weight | normal, bold, or 1–1000 |
font-style | normal, italic, oblique |
letter-spacing | Points, or a string such as "0.08em" |
indent | Length; first line |
hanging | Length; later lines |
space-before | Length above the block |
unit | Unit for this tag's lengths |
id | Link target |
Inline — span
font-size, color, letter-spacing, font-family, font-weight,
font-style, offset (a length), unit.
Page — page
size, width, height, unit, margin, binding, flow, id.
Image — img
src, width, alt, id, unit.
Table — table, cell, rule
| Tag | Properties |
|---|---|
table | columns, align (array), id |
cell | header, span, rows, align |
rule | height, width, column, color, from, to |
Containers and structure
| Tag | Properties |
|---|---|
col, div, section, body, bib | gap, keep, id |
row | gap, keep; children take width or weight |
columns | count, gap, unit |
float | placement, cols |
a | to or href |
footnote | label |
doc, head, title, meta | Metadata; see Documents |
An unrecognized property on a tag is not silently applied. Unknown block or
inline tags are reported (unknown-block, inline-element) and their content
is kept.
Lengths and units
- A length on a tag uses that tag's
unit; nothing inherits it. - The default unit is millimetres.
- Units:
mm,cm,in,pt,pc,px(0.75 pt). - Typographic sizes —
font-size, numericletter-spacing— are always points and ignoreunit. leadingis a ratio, so it carries no unit and no suffix.
<p unit="pt" indent={12}>Twelve points, not twelve millimetres.</p>
Coupled values
Some pairs are alternatives, and stating both is an error rather than a precedence rule:
| Pair | Rule |
|---|---|
indent, hanging | One or the other, never both (indent-hanging) |
size, width/height on a page | size wins; an explicit size plus dimensions is not combined |
to, href on a link | to wins if both are present |
Colour
Named colours, #rgb, #rrggbb, #rrggbbaa, and rgb() with optional alpha:
color="navy"
color="#b23a24"
color="#b23a2480"
color="rgb(178 58 36 / 60%)"
Names: black, white, red, green, blue, navy, gray/grey,
silver, maroon, olive, teal, purple.
Sharing a style
A style that can be written as an object is a value:
export const tight: CellStyle = { font-size: 8, leading: 1.2 };
<DataTable config={tight} />
A project styles a hundred tables from one declaration, and a component carries the appearance of what it generates, so a call site says what and not how.
A shared value costs only the value. There is no rule, no selector, and no indirection through a name that must still be typed everywhere.
Deliberately absent
- stylesheets and rules;
- selectors, classes and ids used for styling;
- cascade and inheritance from containers;
- author-invented names for a look;
- synthetic bold or italic;
- small caps as a switch (use a face).
The id attribute is inert: it exists for links and numbering, never for styling.