Styling
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').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. - 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 box after it is narrowed to the room beside the floats over its whole height, or moves below them when its content does not fit there.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 are rectangles (shapeOutsideis not supported), do not float inside rows or grids, and a box with floats lays its children out top to bottom:flexGrow,flexBasis,justifyContentandalignContentare errors there. - 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.
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/render 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. - Not supported: variants (
md:,hover:), 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.
Synced from packages/render/GUIDE.md in the inkoxide repository.