You're reading the v2 beta docs. For the stable release, switch to v1 →
TakumiTakumi

The measure() API

Measure the node layout without rendering it.

measure() returns a node's laid-out size without rendering it. Use it to fit a headline into a fixed width, or to place a badge against the measured box.

import {  } from "takumi-js/node";
import {  } from "takumi-js/helpers/jsx";

const  = new ();
const { ,  } = await (< ="text-xl">I'm a text node</>);

const { ,  } = await .(, {  });

Returned fields

measure() resolves to a MeasuredNode:

FieldTypeDescription
widthnumberLaid-out width.
heightnumberLaid-out height.
transform[number, number, number, number, number, number]Transformation matrix.
childrenMeasuredNode[]Measured child nodes.
runsMeasuredTextRun[]Text runs in the node, each with x, y, width, height.
Edit on GitHub

Last updated on

On this page