Skip to content

useLayout

function useLayout(nodeRef?): LayoutRect;

Subscribe to the computed layout of a node.

Returns a LayoutRect that updates whenever the layout engine recalculates positions (e.g. on resize or content change).

ParameterTypeDescription
nodeRef?{ current: GlyphNode | null; }React ref pointing to the target GlyphNode.
nodeRef.current?GlyphNode | null-

LayoutRect

Current layout rectangle (outer + inner bounds).

const boxRef = useRef<GlyphNode>(null);
const layout = useLayout(boxRef);
<Box ref={boxRef}>
<Text>Width: {layout.innerWidth} Height: {layout.innerHeight}</Text>
</Box>