Skip to main content
Every JSX node accepts a style object. Dimensions and spacing use native density-independent units unless a property explicitly accepts a percentage string. Styles apply only to the node where you set them. They do not inherit or cascade to descendants. Set typography, color, spacing, and other values explicitly on each node that needs them. This is also true for registered class styles. text is the inline-text exception for children, not for style inheritance. A text node can contain nested text nodes, and each nested text node can contribute its own inline styling. Nodes such as box, row, column, img, or button nested inside text are ignored as text children; place them beside the text node in a layout container instead. See the text node reference for an example.

Property reference

Colors and backgrounds

Shape and borders

Corner names use logical start/end so they work with the app’s layout direction.

Spacing and layout

For scrollable and pager, prefer padding for edge spacing because margin reduces the usable scroll area.

Size

Alignment

How layout alignment works

horizontalAlignment and verticalAlignment are applied by the parent container to its direct children. They do not change the alignment of descendants deeper in the tree. Set the property on the box, row, or column that owns the children you want to align.

Container behavior

The default alignment is start horizontally and top vertically. start and end are logical directions, so they follow the app’s layout direction.

box: align overlaid children

box measures its children in the same bounds and uses both alignment properties to place them. This is useful for badges, overlays, and centered empty states.
The image and text occupy the same box. The text is centered horizontally and placed at the bottom of the box. Render order still controls which child is on top.

row: main-axis and cross-axis alignment

For a row, horizontal alignment controls the child group along the row. Vertical alignment controls each child across the row’s height.
The children are grouped at the logical end of the available width and centered vertically. The vertical alignment is visible because the row has more height than its content. Use a child weight to consume remaining horizontal space. Weighted children share that space proportionally; weight has no layout effect on a child inside a box.

column: main-axis and cross-axis alignment

For a column, vertical alignment controls the child group along the column. Horizontal alignment controls each child across the column’s width.
The child group is centered vertically and each child is centered horizontally. The column needs extra height for vertical alignment to have visible room to move the group. Use a child weight to consume remaining vertical space:

Alignment versus text alignment

These properties act at different levels: To center a heading both within its container and within its own width, use the container’s horizontalAlignment: "center" and the text node’s textAlignment: "center".

Spacing, padding, and margin

  • spacing is a parent layout gap. It is horizontal in a row and vertical in a column.
  • padding adds space inside the container, so alignment and child layout happen inside the remaining content area.
  • margin adds space outside the node. It changes the node’s placement in its parent; it does not create a gap between that node’s own children.
  • On box, spacing does not arrange overlaid children. Use padding, explicit sizes, or a row/column when you need regular gaps.
Alignment only has extra space to distribute when the container is larger than its content. Give a container an explicit or weighted size when you need to see centered or end-aligned content.

Spacing in layout and scrolling nodes

spacing is interpreted by the node that owns the children. It is not a universal margin and it does not add space around the outside edge of a node.

row and column

Use spacing on the parent instead of adding margins to every child:
In a row the gap is horizontal. In a column it is vertical. spacing applies between children, not before the first or after the last; use padding for those edges.

scrollable

scrollable uses spacing between direct scroll items. Use padding for the viewport and content edges:
For a vertical scrollable, omit horizontal; the same spacing becomes the vertical gap. Do not use margin on the scrollable for leading or trailing edge space because it reduces the usable scroll area.

pager

pager uses spacing as the distance between pages, not as an inner gap within each page. Use the page’s own padding for inner content and the pager’s padding for viewport edges:

Typography

Transforms and opacity

Transforms do not change layout measurement; they move or resize the rendered result.

Gradients

Use helpers from @napps/nodes:
Available helpers are linearGradient, radialGradient, sweepGradient, conicGradient, and stop. Structured gradients accept type, angle, centerX, centerY, center, radius, colors, stops, and positions.

Named styles

StyleRegistry stores reusable styles globally within the runtime:
Names are global. Prefix them with the component or extension name to avoid collisions. A class applies only to the node where it is declared; it does not cascade.

Interaction feedback

Do not rely on style.transition for pressed or selected interaction feedback. A gesture has a native lifecycle, so use gestureDetector with a shared value when the visual change needs to be reliable or animated. Use React state and a normal style update when the selected state does not need animation.
Keep the detector around the smallest subtree that needs the interaction. Use onFinalize to restore the visual state when the gesture ends or is cancelled.

Styling best practices

  • Prefer padding over margin for scrollable and pager edge spacing.
  • Prefer spacing on a parent row or column for consistent child gaps.
  • Use weight for proportional space in linear layouts.
  • Use clip when rounded corners should clip child content.
  • Keep layout values stable and use React state for visual changes.
  • Do not rely on style.transition for pressed or selected interaction feedback; use gestureDetector with shared values and animatedProps when feedback must animate.