Layout Engine

How Yoga flexbox integrates per SootSimNode — calculateLayout, the supported style props for flex/alignment/spacing/positioning, and how text uses CanvasKit font metrics through measureFunc to participate in layout.

SootSim uses Yoga (the same layout engine as React Native) for flexbox computation.

Yoga integration

Every SootSimNode gets a corresponding Yoga node. When the tree is committed, SootSim:

  1. creates/updates Yoga nodes for new/changed SootSimNodes
  2. applies style properties as Yoga config
  3. calls yogaRoot.calculateLayout() to compute layout
  4. reads computed values (x, y, width, height) back into SootSimNodes
  5. computes absolute positions by walking the tree

Supported styles

All standard React Native flexbox properties:

  • flex, flexGrow, flexShrink, flexBasis
  • flexDirection (row, column, row-reverse, column-reverse)
  • alignItems, alignSelf, alignContent
  • justifyContent
  • flexWrap
  • gap, rowGap, columnGap
  • padding*, margin*, border*Width
  • width, height, minWidth, maxWidth, minHeight, maxHeight
  • position (relative, absolute)
  • top, left, right, bottom
  • aspectRatio
  • display (flex, none)
  • overflow (visible, hidden, scroll)

Text measurement

Text nodes use CanvasKit’s font metrics to measure text dimensions. The measured size is set on the Yoga node via the measureFunc callback, allowing text to participate in flexbox layout.

Ready to build?

Run your React Native app in the browser. No simulators, no native toolchain, no waiting.

npm i -g sootsim