Skip to main content

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.

ts
import type { PdfStyle } from '@lupinum/nuxt-pdf'

const pageStyle = {
  color: '#18251d',
  fontFamily: 'Invoice Sans',
  fontSize: 10,
  paddingHorizontal: 48,
  paddingVertical: 40,
} satisfies PdfStyle

Use 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

TypeAccepted valuesNotes
PdfLengthA 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.
PdfPercentageA numeric percentage string such as '50%'Accepted only by properties whose type includes percentages.
ColorA color string such as '#18251d', 'rgb(24, 37, 29)', or 'red'There are no CSS variables or global cascade.
EnumOne of the literals listed belowBrowser-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.

PropertyAccepted valueInheritedBehavior
width, heightPdfLength | PdfPercentageNoSets the resolved box size.
minWidth, minHeight, maxWidth, maxHeightPdfLength | PdfPercentageNoConstrains the resolved box size.
position'relative' | 'absolute'NoUse the component fixed prop to repeat content across pages. Browser fixed and static values are not accepted.
top, right, bottom, leftPdfLength | PdfPercentageNoOffsets 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.

PropertyAccepted valueInheritedBehavior
flexDirection'row' | 'row-reverse' | 'column' | 'column-reverse'NoControls the main axis. The default is column.
flex, flexGrow, flexShrinknumberNoControls available-space growth and shrinkage.
flexBasisPdfLength | PdfPercentage | 'auto'NoSets the initial main-axis size.
flexWrap'nowrap' | 'wrap' | 'wrap-reverse'NoControls flex-line wrapping.
alignItems'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'NoAligns children on the cross axis.
justifyContent'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly'NoDistributes children on the main axis.
gapPdfLengthNoAdds 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.

PropertyAccepted valueInheritedBehavior
margin, marginHorizontal, marginVertical, marginTop, marginRight, marginBottom, marginLeftPdfLength | PdfPercentage | 'auto'NoSets space outside the box.
padding, paddingHorizontal, paddingVertical, paddingTop, paddingRight, paddingBottom, paddingLeftPdfLength | PdfPercentageNoSets space inside the box. Padding does not accept auto.

Borders and paint

PropertyAccepted valueInheritedBehavior
backgroundColorcolor stringOnly through nested PdfText runsPaints the page-flow box background.
colorcolor stringYesSets text color on text-bearing primitives.
opacitynumberYesSets node opacity.
borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidthPdfLengthNoSets all or individual border widths.
borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColorcolor stringNoSets all or individual border colors.
borderStyle, borderTopStyle, borderRightStyle, borderBottomStyle, borderLeftStyle'solid' | 'dashed' | 'dotted'NoSets all or individual border styles.
borderRadiusPdfLengthNoPage-flow primitives. Percent shorthand is not accepted because the engine requires a resolved number.
borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadiusPdfLength | PdfPercentageNoPage-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.

PropertyAccepted valueInheritedBehavior
fontFamilystringYesSelects one registered family or a built-in engine family.
fontSizePdfLengthYesSets glyph size.
fontStyle'normal' | 'italic' | 'oblique'YesSelects the matching registered face.
fontWeightnumber or thin, hairline, ultralight, extralight, light, normal, medium, semibold, demibold, bold, ultrabold, extrabold, heavy, blackYesSelects the matching registered numeric weight.
letterSpacingPdfLengthYesAdds space between glyphs and affects wrapping.
lineHeightunitless multiplier, PdfLength, or PdfPercentageYes for static textStatic text supports it. Dynamic render text uses font-default line spacing; see Supported behavior.
maxLinesnumberNoLimits rendered lines. Use textOverflow: 'ellipsis' for an ellipsis.
textAlign'left' | 'right' | 'center' | 'justify'YesAligns text inside its line box.
textDecoration'none' | 'underline' | 'line-through' or both decoration names separated by a spaceYesApplies one or both decorations.
textDecorationColorcolor stringNoPdfText and PdfLink.
textDecorationStyle'solid' | 'dashed' | 'dotted'NoPdfText and PdfLink.
textOverflow'ellipsis'NoAdds an ellipsis when maxLines truncates text.
textTransform'none' | 'capitalize' | 'lowercase' | 'uppercase'YesTransforms 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

PropertyAccepted valueInheritedBehavior
objectFit'contain' | 'cover'NoFits a PdfImage inside its resolved box.
transformOne to three space-separated rotate(...), scale(...), or translate(...) operationsNoApplies 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:

ts
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 PdfStyleValue

Numbers, strings, true, functions, and arbitrary objects are not valid array entries.

Exported style types

Import these types from @lupinum/nuxt-pdf:

ExportDescribes
PdfStyleOne style object
PdfStyleValueOne style object or a nested style array
PdfStyleEntryOne accepted entry in a style array
PdfLengthA point number or supported length string
PdfPercentageA numeric percentage string
PdfLengthOrPercentageA supported length or percentage