Skip to content

1681-engine / ui / listWidth

Function: listWidth() ​

ts
function listWidth(
   labels, 
   measure, 
   options?
): number;

Defined in: src/ui/layout/listWidth.ts:13

How wide a drop-down list (or a menu) must be so its longest label fits: measured, not guessed, so no label is clipped. measure is the caller's (a canvas measureText, a bitmap font's advance sum). Rounded up to a whole pixel so the measurement never loses the last half pixel of a letter.

Parameters ​

ParameterType
labelsreadonly string[]
measure(label) => number
optionsListWidthOptions

Returns ​

number

Released under the MIT License.