Styles
Accepted style keys, values, units, inheritance, and primitive support.
PdfStyle is Nuxt PDF's framework-owned authoring contract. It
contains the behavior this package tests and supports; it does not re-export
the wider upstream stylesheet types and it is not browser CSS.
import type { PdfStyle } from '@lupinum/nuxt-pdf'
const pageStyle = {
color: '#18251d',
fontFamily: 'Invoice Sans',
fontSize: 10,
paddingHorizontal: 48,
paddingVertical: 40,
} satisfies PdfStyleUse satisfies, not a type assertion. It preserves the object's useful
inferred type while making vue-tsc reject unknown keys, invalid enums, and
unsupported units.
PdfStyle belongs to page-flow layout and text metrics. SVG paint and geometry
use direct props: PdfG and shapes do not accept style, PdfSvg.style places
the SVG root in page flow, and SVG PdfText.style controls text metrics while
its direct fill prop controls paint.
Values and units
| Type | Accepted values | Notes |
|---|---|---|
PdfLength | A number, or pt, px, in, mm, cm, rem, vh, or vw (for example 12, '12pt', '4mm') | A unitless number is a PDF point. px uses the page DPI; the default is 72. |
PdfPercentage | A numeric percentage string such as '50%' | Accepted only by properties whose type includes percentages. |
| Color | A color string such as '#18251d', 'rgb(24, 37, 29)', or 'red' | There are no CSS variables or global cascade. |
| Enum | One of the literals listed below | Browser-only values are rejected even when a similarly named CSS property exists. |
rem uses the engine's 18-point base. vw and vh resolve against the PDF
page container, not a browser window. Percentages resolve against the relevant
parent dimension.
em, ch, ex, calc(), var(), container queries, and arbitrary CSS
strings are not part of the contract.
Dimensions and positioning
These keys are valid on page-flow primitives (PdfPage, PdfView, PdfText,
PdfImage, PdfLink, and PdfNote). width and height also size PdfSvg
inside page flow.
| Property | Accepted value | Inherited | Behavior |
|---|---|---|---|
width, height | PdfLength | PdfPercentage | No | Sets the resolved box size. |
minWidth, minHeight, maxWidth, maxHeight | PdfLength | PdfPercentage | No | Constrains the resolved box size. |
position | 'relative' | 'absolute' | No | Use the component fixed prop to repeat content across pages. Browser fixed and static values are not accepted. |
top, right, bottom, left | PdfLength | PdfPercentage | No | Offsets a positioned node. |
Flex layout
Flex properties primarily belong on PdfPage and PdfView. Text, links,
images, notes, and SVGs can be flex items. The engine defaults to a column
direction.
| Property | Accepted value | Inherited | Behavior |
|---|---|---|---|
flexDirection | 'row' | 'row-reverse' | 'column' | 'column-reverse' | No | Controls the main axis. The default is column. |
flex, flexGrow, flexShrink | number | No | Controls available-space growth and shrinkage. |
flexBasis | PdfLength | PdfPercentage | 'auto' | No | Sets the initial main-axis size. |
flexWrap | 'nowrap' | 'wrap' | 'wrap-reverse' | No | Controls flex-line wrapping. |
alignItems | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline' | No | Aligns children on the cross axis. |
justifyContent | 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' | No | Distributes children on the main axis. |
gap | PdfLength | No | Adds space between flex children. |
There is no grid, browser block layout, floats, selectors, or CSS cascade.
Box model
The box model is valid on page-flow primitives. Percentages resolve through the engine's PDF layout container, not a browser viewport.
| Property | Accepted value | Inherited | Behavior |
|---|---|---|---|
margin, marginHorizontal, marginVertical, marginTop, marginRight, marginBottom, marginLeft | PdfLength | PdfPercentage | 'auto' | No | Sets space outside the box. |
padding, paddingHorizontal, paddingVertical, paddingTop, paddingRight, paddingBottom, paddingLeft | PdfLength | PdfPercentage | No | Sets space inside the box. Padding does not accept auto. |
Borders and paint
| Property | Accepted value | Inherited | Behavior |
|---|---|---|---|
backgroundColor | color string | Only through nested PdfText runs | Paints the page-flow box background. |
color | color string | Yes | Sets text color on text-bearing primitives. |
opacity | number | Yes | Sets node opacity. |
borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth | PdfLength | No | Sets all or individual border widths. |
borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor | color string | No | Sets all or individual border colors. |
borderStyle, borderTopStyle, borderRightStyle, borderBottomStyle, borderLeftStyle | 'solid' | 'dashed' | 'dotted' | No | Sets all or individual border styles. |
borderRadius | PdfLength | No | Page-flow primitives. Percent shorthand is not accepted because the engine requires a resolved number. |
borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius | PdfLength | PdfPercentage | No | Page-flow primitives; edge radii are resolved independently. |
Full CSS border strings such as '1px solid red' are not public authoring
syntax. Use the explicit width, style, and color keys so invalid values remain
type-checkable.
Text
Text keys apply to PdfText and PdfLink. They may be set on ancestor
PdfPage/PdfView nodes when the table marks them inherited.
| Property | Accepted value | Inherited | Behavior |
|---|---|---|---|
fontFamily | string | Yes | Selects one registered family or a built-in engine family. |
fontSize | PdfLength | Yes | Sets glyph size. |
fontStyle | 'normal' | 'italic' | 'oblique' | Yes | Selects the matching registered face. |
fontWeight | number or thin, hairline, ultralight, extralight, light, normal, medium, semibold, demibold, bold, ultrabold, extrabold, heavy, black | Yes | Selects the matching registered numeric weight. |
letterSpacing | PdfLength | Yes | Adds space between glyphs and affects wrapping. |
lineHeight | unitless multiplier, PdfLength, or PdfPercentage | Yes for static text | Static text supports it. Dynamic render text uses font-default line spacing; see Supported behavior. |
maxLines | number | No | Limits rendered lines. Use textOverflow: 'ellipsis' for an ellipsis. |
textAlign | 'left' | 'right' | 'center' | 'justify' | Yes | Aligns text inside its line box. |
textDecoration | 'none' | 'underline' | 'line-through' or both decoration names separated by a space | Yes | Applies one or both decorations. |
textDecorationColor | color string | No | PdfText and PdfLink. |
textDecorationStyle | 'solid' | 'dashed' | 'dotted' | No | PdfText and PdfLink. |
textOverflow | 'ellipsis' | No | Adds an ellipsis when maxLines truncates text. |
textTransform | 'none' | 'capitalize' | 'lowercase' | 'uppercase' | Yes | Transforms rendered text casing. |
wordSpacing is not supported. The pinned text layout pipeline accepts
the key but does not apply it to glyph advances or wrapping. Nuxt PDF does not
type a no-op as supported authoring; use letterSpacing instead.
Images and transforms
| Property | Accepted value | Inherited | Behavior |
|---|---|---|---|
objectFit | 'contain' | 'cover' | No | Fits a PdfImage inside its resolved box. |
transform | One to three space-separated rotate(...), scale(...), or translate(...) operations | No | Applies to page-flow primitives. Rotate accepts degrees or radians. Translate uses unitless PDF points. SVG transforms remain direct SVG props. |
Style arrays
PdfStyleValue is either one PdfStyle or a recursively nested readonly array.
Arrays merge left-to-right. false, null, and undefined entries are ignored,
which makes Vue conditionals direct and type-safe:
import type { PdfStyle, PdfStyleValue } from '@lupinum/nuxt-pdf'
const base = { fontSize: 10 } satisfies PdfStyle
const total = { fontWeight: 700 } satisfies PdfStyle
const style = [base, [isTotal && total], null] satisfies PdfStyleValueNumbers, strings, true, functions, and arbitrary objects are not valid array
entries.
Exported style types
Import these types from @lupinum/nuxt-pdf:
| Export | Describes |
|---|---|
PdfStyle | One style object |
PdfStyleValue | One style object or a nested style array |
PdfStyleEntry | One accepted entry in a style array |
PdfLength | A point number or supported length string |
PdfPercentage | A numeric percentage string |
PdfLengthOrPercentage | A supported length or percentage |