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:
| Field | Type | Description |
|---|---|---|
width | number | Laid-out width. |
height | number | Laid-out height. |
transform | [number, number, number, number, number, number] | Transformation matrix. |
children | MeasuredNode[] | Measured child nodes. |
runs | MeasuredTextRun[] | Text runs in the node, each with x, y, width, height. |
Edit on GitHub
Last updated on