Skip to content

visibleWidth

Generated reference page for the visibleWidth function export.

Signatures

ts
function visibleWidth(text: string): number;
ParameterTypeDescription
textstringText possibly containing terminal escapes.

Members

Members

visibleWidth

Measure the visible column width of text, ignoring ANSI/OSC escapes.

Escape sequences (SGR colors, OSC 8 hyperlinks) occupy zero columns when rendered, so .length overcounts whenever they are present. Help formatting uses this for padding and wrapping; exported for custom help renderers that mix colors or links into aligned output.

ts
(text: string): number;

Examples

ts
visibleWidth('plain');                     // 5
visibleWidth(osc8('https://x.dev', 'x')); // 1

See Also

Released under the MIT License.