Styling
The code on this page is React’s. How Vue writes it
| React | Vue | |
|---|---|---|
| Classes | className="p-4" | class="p-4" |
| Props | headerRows={1} | :header-rows="1" or :headerRows="1" |
A prop that is true | hyphenate | hyphenate |
| Content per page | render={({ pageNumber }) => …} | <template #render="{ pageNumber, totalPages }">…</template> |
| The page, deeper down | usePage() | usePage() (it injects the page) |
| What to render | <Invoice invoice={invoice} /> | h(Invoice, { invoice }) |
A template for generate | Template: ComponentType<{ data }> | Template: a component with the prop data |
The rest, and Vue’s own API, is in the Vue guide.
The code on this page is React’s. How Svelte writes it
| React | Svelte | |
|---|---|---|
| Classes | className="p-4" | class="p-4" (a list or an object of flags too) |
| Content per page | render={({ pageNumber }) => …} | {#snippet render(page)}{page.pageNumber}{/snippet} inside the Text or View |
| The page, deeper down | usePage() | usePage(), while the component is created |
| What to render | <Invoice invoice={invoice} /> | { component: Invoice, props: { invoice } } |
A template for generate | Template: ComponentType<{ data }> | Template: a component with the prop data |
The rest, and Svelte’s own API, is in the Svelte guide.
The code on this page is React’s. How Angular writes it
| React | Angular | |
|---|---|---|
| Components | <View>, <Path>, <TextField> | <ink-view>, <ink-path>, <ink-text-field>: ink- and the name in kebab case |
| Classes | className="p-4" | class="p-4", [class]="…" |
| Props | headerRows={1}, size="A4" | [headerRows]="1", size="A4" (an attribute is a string: bind numbers) |
A prop that is true | hyphenate | hyphenate |
| Style | style={{ padding: 20 }} | [style]="{ padding: 20 }"; [inkStyle] for @media blocks and lists of styles |
| Content per page | render={({ pageNumber }) => …} | [render]="footer" with <ng-template #footer let-page>{{ page.pageNumber }}</ng-template> |
| The page, deeper down | usePage() | injectPage() |
| What to render | <Invoice invoice={invoice} /> | { component: Invoice, inputs: { invoice } } |
A template for generate | Template: ComponentType<{ data }> | Template: a component with the input data |
The rest, and Angular’s own API, is in the Angular guide.
Style objects
<View style={{ padding: 12, borderBottomWidth: 0.5, borderBottomColor: '#ddd' }} />
<View style={[styles.row, index % 2 === 1 && styles.zebra]} />
<Text style={{ fontSize: '9pt', marginTop: '2mm' }} />
-
Units. Numbers are points (1/72 inch). Strings may use
pt,mm,cm,in,px(0.75pt),pc(12pt),rem(12pt, as in Tailwind),em(the element's font size; infontSize, the inherited one; inlineHeightandletterSpacing, the size of the text they apply to, so they scale with each run),vwandvh(1% of the page's width and height), or a percentage.lineHeightis a multiplier of the text size (1.4,'140%','1.4em') or a length ('14pt'), which is read as that multiple of the text's own size: a larger run on the line makes the line taller than the length.calc()adds lengths ('calc(10mm + 1em)') or percentages, but not one to the other. A class's arbitrary value (w-[…]) takes the same syntax and reads the same. A page'ssizetakes the units that do not depend on the font or the page. Percentages follow CSS: widths, padding and margins are of the parent's width, and gaps of the element's own size. A percentage height needs a parent with a set height; a child of thePagetakes it of the page. -
Arrays. Falsy entries are skipped and later entries win, over
classNametoo, as a later CSS rule does: a laterborderRadius: 8replaces an earlier corner's radius. -
Shorthands.
padding,margin,paddingHorizontal/paddingVertical, per-side keys andflex: 1(meaning1 1 0%) all work.borderandborderTop,borderRight,borderBottom,borderLefttake CSS strings ('1px solid #e5e7eb','2pt dashed red','none'); a missing style is solid and a missing colour is the text colour. A side wins overborder, andborderWidth,borderColor,borderStyleand the per-side keys win over both.insetsetstop,right,bottomandleftat once (one value, or{ top, right, bottom, left }), and those keys win over it. -
Indents.
textIndent(indent-*) indents the first line of aText. A negative value is a hanging indent: the first line starts that far before the others, so give theTextas muchpaddingLeft(-indent-4 pl-4). -
CSS names.
textDecorationtakes'underline','line-through'or both; a run has one line, so'underline line-through'draws the line-through.textDecorationColor,textDecorationStyleandtextDecorationThicknessare the same asdecorationColor,decorationStyleanddecorationThickness.textOverflow: 'ellipsis'isellipsis: true(withmaxLines).objectFiton anImageorImageBackgroundis itsfitprop, which wins when both are set.objectPositionon them places the image in its box (see Images). Both throw on other elements. -
Floats.
float: 'left'or'right'(float-left,float-right) on a child of a columnView, aPageor aCellputs it at that side, as narrow as its content unless it has a width, at or below where it comes in the flow. Text after it wraps beside it line by line, in its own box: aTextwith a width, analignSelfor auto side margins keeps the box it would have without the float, and its lines take the room the float leaves in it. A columnViewafter it, with children and no floats of its own, keeps its width too and lays its children out beside the floats, so that its text wraps beside them in turn (8 suchViews deep). Other boxes after it (anImage, a row, a grid, a table, aViewwithoverflow: 'hidden'or anaspectRatio) are narrowed to the room beside the floats over their whole height, or move below them when their content does not fit there.shapeOutsidegives a float a shape for the lines beside it to wrap around, as CSSshape-outside:'circle(50%)','ellipse(40% 50% at left)','inset(0 0 20% round 8pt)'or'polygon(0 0, 100% 0, 0 100%)'in its margin box ([shape-outside:circle(50%)]as a class), andshapeMarginkeeps the lines that far from it; the float is still placed, and boxes narrowed, by its margin box.clear: 'left','right'or'both'moves an element below the floats before it, and a parent is as tall as its floats. A float moves to the next page with the lines beside it. Floats do not float inside rows or grids, and a box with floats lays its children out top to bottom: the room they leave goes toflexGrowandjustifyContent, andflexGrowon a float,flexBasison the box's children andalignContentare errors. -
Opacity.
opacityapplies to each element, not to an element and its children as one group, as CSS does: where children overlap, each shows through the others.opacity: 0draws nothing, and leaves out the links, form fields and notes of everything inside the element. -
Inheritance. Text properties (font, size, weight, colour, line height, alignment) pass down from
PageandViewto the text inside. Box properties apply only to the element that has them. -
Page media. An
'@media …'key holds styles for the pages it matches, so one component can fit the page it lands on:const styles = StyleSheet.create({ grid: { flexDirection: 'column', '@media (orientation: landscape)': { flexDirection: 'row', gap: 24 }, '@media (width < 150mm)': { fontSize: 9 }, }, });A query reads the page:
widthandheight(the whole sheet, margins included, asvwandvhdo),aspect-ratioandorientation(a square page is portrait), withmin-/max-or the range forms ((400pt <= width < 600pt)), joined byand,or,notand commas.printandallmatch,screendoes not. Lengths takept,mm,cm,in,px,pcandrem, and are compared to 1/100 pt, so(max-width: 210mm)holds on A4. Blocks apply after the object's own properties, in the order written, and may nest, at most 32 deep (all their queries must match); a later entry of a style array still wins. A block for another page size is read too, so a mistake in it fails on every page. Features of screens (hover,prefers-color-scheme,resolution) are errors. EachPagehas one size, so the queries are answered once per page, before layout; a JSON document has no@media(its author knows each page's size).
Tailwind
Write the classes you would write on the web. They are resolved by the Tailwind v4 compiler, in
@inkoxide/tailwind, which you install next to @inkoxide/react when you use className:
npm install @inkoxide/tailwind
Without it, style works the same, and a className fails with an error that says to install
it.
- Units are tuned for print:
1rem = 12ptand1px = 0.75pt. Sop-4is 12pt,text-smis 10.5pt andtext-xsis 9pt. Use arbitrary values for exact sizes:text-[9.5pt],mt-[14pt],w-[60mm]. - Supported: flexbox, grid, sizing, spacing, the full colour palette with opacity
(
bg-black/5), borders, per-corner radii, typography,absolutepositioning withz-*, and 2D transforms. - Page variants read the page as
@mediadoes:md:p-4,max-sm:text-xs,min-[200mm]:flex-row,landscape:flex-row,print:hidden, and stacked,sm:landscape:. Breakpoints are Tailwind's:sm480pt,md576pt (A4 and Letter portrait are wider),lg768pt (their landscape is wider),xl960pt,2xl1152pt; a theme can add its own (--breakpoint-a4: 49.6067rem, which is 595.28pt, givesa4:andmax-a4:). Write them inrem: Tailwind sorts breakpoints of different units by unit, not by size, so one inptcomes beforesm:and loses to it. - Not supported: variants for screens and states (
hover:,focus:,dark:), container queries (@sm:), shadows, gradients andspace-*/divide-*(usegap-*and borders). Using one throws and names the class; in production (NODE_ENV=production) it is logged once and ignored. - In a browser, the Tailwind compiler is about 90 KB to download with brotli. The build
plugin of
@inkoxide/tailwindreplaces it with a table of the classes your sources use, a few KB (@inkoxide/tailwindREADME):plugins: [inkoxideTailwind()]in a Vite config (inkoxideTailwindEsbuild()for esbuild,inkoxideTailwindWebpack()for webpack and Rspack), orwithInkoxideTailwind(nextConfig)innext.config.tsfor Next.js 15.3 or later, with Turbopack or webpack. The theme's@sourcedirectives add to what it scans. Then write each class whole: one put together at run time (`bg-${color}-500`) is not in the table, unless it is in the plugin'ssafelist. With Turbopack,next devscans when it starts: restart it for a class that is new since.
Synced from packages/react/GUIDE.md in the inkoxide repository.